program cow;
{$o-}
{$APPTYPE CONSOLE}
uses
 Math, StrUtils, SysUtils;
type
 ex=extended;
 int=longint;
 bool=boolean;
var
 a,b,c: array [1..10] of int;
 f: bool;
 i,j,n,y,z: int;
 s: string;

function check(s,t: string; a,b: int): bool;
var
 i,c,d: int;
begin
c:= 0;
d:= 0;
for i:= 1 to 4 do
 if pos(s[i],t)=i
  then
   inc(c)
  else
   if pos(s[i],t)>0
    then
     inc(d);
result:= (a=c)and(b=d);
end;

function conv(n: int): string;
begin
result:= inttostr(n);
if n<1000
 then
  result:= '0'+result;
end;

function ok(n: int): bool;
var
 a,b,c,d: int;
begin
a:= n mod 10;
n:= n div 10;
b:= n mod 10;
n:= n div 10;
c:= n mod 10;
d:= n div 10;
result:= not((a=b)or(a=c)or(a=d)or(b=c)or(b=d)or(c=d));
end;

begin
readln(n);
y:= 0;
z:= 0;
for i:= 1 to n do
 readln(a[i],b[i],c[i]);
for i:= 123 to 9876 do
 begin
 if not ok(i)
  then
   continue;
 s:= conv(i);
 f:= true;
 for j:= 1 to n do
  f:= f and check(s,conv(a[j]),b[j],c[j]);
 if f
  then
   begin
   inc(z);
   y:= i;
   end;
 end;
if z=1
 then
  writeln(y)
 else
  if z=0
   then
    writeln('Incorrect data')
   else
    writeln('Need more data');
//readln;    
end.