import java.util.*;
class D {
public void run() {
Scanner sc
= new Scanner
(System.
in); for (int n = sc.nextInt(); n > 0; n = sc.nextInt()) {
int[] x = new int[n];
int[] y = new int[n];
int[] r = new int[n];
int[] c = new int[n];
for (int i = 0; i < n; i++) {
x[i] = sc.nextInt();
y[i] = sc.nextInt();
r[i] = sc.nextInt();
c[i] = sc.nextInt();
}
boolean[][] on = new boolean[n][n];
for (int i = 0; i < n; i++)
for (int j = 0; j < i; j++)
on[i][j] = check(x[i] - x[j], y[i] - y[j], r[i] + r[j]);
boolean[] left = new boolean[n];
for (int i = 0; i < n; i++)
left[i] = true;
map.clear();
System.
out.
println(dfs
(n, on, c, left
)); }
}
private int dfs(int n, boolean[][] on, int[] c, boolean[] left) {
int key = toi(left);
if (map.containsKey(key))
return map.get(key);
int max = 0;
loop1: for (int i = 0; i < n; i++)
if (left[i]) {
for (int k = 0; k < i; k++)
if (left[k] && on[i][k])
continue loop1;
loop2: for (int j = 0; j < n; j++)
if (left[j] && i != j && c[i] == c[j]) {
for (int k = 0; k < j; k++)
if (left[k] && on[j][k])
continue loop2;
left[i] = left[j] = false;
max
= Math.
max(max,
2 + dfs
(n, on, c, left
)); left[i] = left[j] = true;
}
}
map.put(key, max);
return max;
}
int toi(boolean[] bs) {
int ret = 0;
for (boolean b : bs) {
ret <<= 1;
if (b)
ret++;
}
return ret;
}
boolean check(int dx, int dy, int rr) {
return dx * dx + dy * dy < rr * rr;
}
new D().run();
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgRCB7CgoJcHVibGljIHZvaWQgcnVuKCkgewoJCVNjYW5uZXIgc2MgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWZvciAoaW50IG4gPSBzYy5uZXh0SW50KCk7IG4gPiAwOyBuID0gc2MubmV4dEludCgpKSB7CgkJCWludFtdIHggPSBuZXcgaW50W25dOwoJCQlpbnRbXSB5ID0gbmV3IGludFtuXTsKCQkJaW50W10gciA9IG5ldyBpbnRbbl07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