program mesh_bin_txt;
{$APPTYPE CONSOLE}
uses
  SysUtils;
type
  nume = array [0..25000] of string[100];
  tree = array [0..50000] of string[50];
  keyd = array [0..25000] of string[7];
  rela = array [0..50000] of longint;
var
  f:text;
  s:string;
  n,t,i:longint;
  nd:nume;
  td:tree;
  kd:keyd;
  tk:rela;
function spal(var s:string):string;
begin
  delete(s,1,5);
  spal := s;
end;
begin
  writeln('Begin');
  assign(f,'c:\lori\mesh\d2004.bin');
  reset(f);
  n := 0;
  t := 0;
  while(not(eof(f)))do begin
   readln(f,s);
   if(pos('MH = ',s)>0)then begin
    n := n + 1;
    nd[n] := spal(s);
   end;
   if(pos('MN = ',s)>0)then begin
    t := t + 1;
    td[t] := spal(s);
    tk[t] := n;
   end;
   if(pos('UI = ',s)>0)then begin
    kd[n] := spal(s);
   end;
  end;
  close(f);
  assign(f,'desctree.txt');
  rewrite(f);
  for i := 1 to t do
   writeln(f,kd[tk[i]],chr(9),td[i],chr(9),nd[tk[i]]);
  close(f);
  writeln('End');
  readln;
end.
