{$apptype console}
{$R+,O-}
{
This program delete equal pairs from first_fres.txt file.
The program writes result to fres.txt file.
This file contains pairs $(n(w),|w|)$.
}
var
  f:text;
  {array that contains pair from fres.txt file}
  data:array[1..200000,1..2] of integer;
  {number of pairs}
  ndata:integer;
{Read pairs from first_fres.txt file and store them in data array.}  
procedure loaddata;
var
  s:string;
  i:integer;
  code:integer;
  s1:string;
begin
  ndata:=0;
  while not eof(f) do
  begin
    {data is written in $w$/$n(w)$ format}
    readln(f,s);
    i:=pos('/',s);
    if i=0 then halt;
    s1:=copy(s,1,i-1);{s1 contains $w$ now}
    delete(s,1,i);{s contains $n(w)$ now}
    inc(ndata);
    {convert strings to numbers}
    val(s1,data[ndata,1],code);
    if code<>0 then halt;
    val(s,data[ndata,2],code);
    if code<>0 then halt;
  end;
end;
{lexicographical comparing of pairs}
function cmp(a,b:integer):boolean;
begin
  if data[a,1]<>data[b,1] then
    cmp:=data[a,1]<data[b,1]
  else
    cmp:=data[a,2]<data[b,2];
end;
{Transposition of pairs.}
procedure trans(a,b:integer);
var
  t:integer;
begin
  t:=data[a,1];data[a,1]:=data[b,1];data[b,1]:=t;
  t:=data[a,2];data[a,2]:=data[b,2];data[b,2]:=t;
end;
{Bounce procedure in heap sorting algorithm}
procedure heap(a:integer);
var
  x,nx:integer;
begin
  x:=a;
  while (2*x<=ndata) do
  begin
    if cmp(x,2*x) then nx:=2*x else nx:=x;
    if 2*x+1<=ndata then
      if cmp(nx,2*x+1) then nx:=2*x+1;
    if x=nx then break;
    trans(x,nx);
    x:=nx;
  end;
end;
{Main procedure in heap sorting algorithm}
procedure sort;
var
  i:integer;
  prevn:integer;
begin
  prevn:=ndata;
  for i:=ndata downto 1 do
    heap(i);
  while ndata>1 do
  begin
    trans(1,ndata);
    dec(ndata);
    heap(1);
  end;
  ndata:=prevn;
end;
{Calculate unique pairs}
procedure solve;
var
  i,j:integer;
begin
  sort;
  j:=1;
  for i:=2 to ndata do
  begin
    if (data[i,1]<>data[i-1,1]) or (data[i,2]<>data[i-1,2]) then
    begin
      inc(j);
      data[j,1]:=data[i,1];
      data[j,2]:=data[i,2];
    end;
  end;
  ndata:=j;
end;
{Save unique pairs to the file}
procedure writedata;
var
  i:integer;
begin
  writeln(f,ndata);
  for i:=1 to ndata do
  begin
    writeln(f,data[i,1],' ',data[i,2]);
  end;
end;
begin
  assign(f,'first_res.txt');
  reset(f);
  loaddata;
  close(f);
  solve;
  assign(f,'fres.txt');
  rewrite(f);
  writedata;
  close(f);
end.