1 var
2 c:array [‘a‘..‘z‘] of longint;
3 s1,s2:ansistring;
4 TT:longint;
5 function fd(cc:char):boolean;
6 begin
7 if (ord(cc)>=97) and (ord(cc)<=122) then
8 exit(true);
9 exit(false);
10 end;
11
12 procedure main;
13 var
14 i,l1,l2:longint;
15 cc:char;
16 begin
17 l1:=length(s1);
18 l2:=length(s2);
19 if l1<>l2 then
20 begin
21 writeln(‘0‘);
22 exit;
23 end;
24 for cc:=‘a‘ to ‘z‘ do
25 c[cc]:=0;
26 for i:=1 to l1 do
27 if s1[i]<>s2[i] then
28 begin
29 if (not fd(s1[i])) or (not fd(s2[i])) then
30 begin
31 writeln(‘0‘);
32 exit;
33 end;
34 if c[s1[i]]=0 then c[s1[i]]:=ord(s2[i]) else
35 if c[s1[i]]<>ord(s2[i]) then
36 begin
37 writeln(‘0‘);
38 exit;
39 end;
40 end;
41 writeln(‘1‘);
42 end;
43
44 begin
45 assign(input,‘copycat.in‘);
46 assign(output,‘copycat.out‘);
47 reset(input);
48 rewrite(output);
49 readln(TT);
50 while TT>0 do
51 begin
52 readln(s1);
53 readln(s2);
54 main;
55 dec(TT);
56 end;
57 close(input);
58 close(output);
59 end.