Test 10,WA,who can give me the test???
program ex;
var a:Array[-32000..32000] of integer;
b:Array[1..100000,1..2] of integer;
i,j,k,n,x,y,z,s,first:longint;
begin
{ assign(input,'1116.in');reset(input);}
read(n);
for i:=-32000 to 32000 do a[i]:=101;
for i:=1 to n do begin
read(x,y,z);
for j:=x to y-1 do
a[j]:=z;
end;
readln;
read(n);
for i:=1 to n do begin
read(x,y,z);
for j:=x to y-1 do
if a[j]<>101 then
a[j]:=101;
end;
k:=0;s:=0;
for i:=-32000 to 32000 do begin
if (a[i]<>101)and(k=0) then begin
k:=1;
first:=i;
end;
if (a[i]=101)and(k=1) then begin
k:=0;
inc(s);
b[s,1]:=first;b[s,2]:=i;
end;
end;
write(s,' ');
for i:=1 to s do
write(b[i,1],' ',b[i,2],' ',a[b[i,1]],' ');
writeln;
{ close(input);}
end.