var array 100 of record name string sum integer end char integer begin

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var р:array[1..100] of record
name:string;
sum:integer;
end;
с:char;
i,j,N,m:integer;
begin
readln(N);
for i:=l to N do
begin
p[i].name: ' ';
repeat
readln(c);
p[i].name:=p[i].name+c
until c=' ';
repeat
read(с);
p[i].name:=p[i].name+c
until c=' ';
p[i].sum:=0;
for j:=1 to 3 do
begin
read(m);
if m=2 then p[i].sum:=p[i].sum+1
end;
readln;
end;
for i:=1 to N do
if p[i].sum=3 then writeln(p[i].name);
for i:=1 to N do
if p[i].sum=2 then writeln(p[i].name);
for i:=1 to N do
if p[i].sum=1 then writeln(p[i].name)
end.