program asd;
uses crt;
const n=7; m=2;
var q,x:array[1..n,1..n] of integer;
var qq:array[1..n] of integer;
a1,s,i,j,v,f:integer; u:real;
BEGIN
clrscr;
randomize;
for j:=1 to n do BEGIN
for i:=1 to n do BEGIN
x[i,j]:=random(30)-2; write(' ',x[i,j]); end; writeln; end;
writeln;
a1:=x[1,1]; f:=1;
for j:=1 to n do
for i:=1 to n do
if x[i,j]=0 then BEGIN f:=j; end;
for j:=1 to n do
for i:=1 to n do BEGIN
a1:=x[i,f];
x[i,f]:=x[i,1];
x[i,1]:=a1;
end;
for j:=1 to n do BEGIN
for i:=1 to n do write(' ',x[i,j]);
writeln; end;
end.