{
Written by Fyodor Menshikov 24.02.2006
6:19-8:04 (no debug!!!)
}
{$R+,Q+}
var
   s:string;
   pos:integer;
   c:char;

   procedure nextchar;
   begin
      if pos<=length(s) then begin
         inc(pos);
      end;
      if pos<=length(s) then begin
         c:=s[pos];
      end
      else begin
         c:=#13;
      end;
   end;

   procedure error(msg:string);
   begin
      writeln('Error: ',msg,' at ',pos);
      halt(1);
   end;

   function isEOT:boolean;
   begin
      isEOT:=pos>length(s);
   end;

   function isNext(need:string):boolean;
   var
      i,j:integer;
   begin
      i:=pos;
      for j:=1 to length(need) do begin
         if (i>length(s)) or (s[i]<>need[j]) then begin
            isNext:=false;
            exit;
         end;
         inc(i);
      end;
      isNext:=true;
   end;

   procedure skip(need:string);
   var
      i:integer;
   begin
      for i:=1 to length(need) do begin
         if isNext(need[i]) then begin
            nextchar;
         end
         else begin
            error(need[i]+' expected');
         end;
      end;
   end;

type
   Ptree=^Ttree;
   Ttree=record
      case kind:(cmp,_and,_or,_not) of
      cmp:(
         cleft,cright:char;
         sign:string[2];
         antisign:string[2];
      );
      _and,_or:(
         pleft,pright:Ptree;
      );
      _not:(
         pexpr:Ptree;
      );
   end;

   procedure expression(var tree:Ptree);forward;

   procedure factor(var tree:Ptree);
   begin
      if isNext('not ') then begin
         skip('not ');
         new(tree);
         tree.kind:=_not;
         factor(tree.pexpr);
      end
      else if c='(' then begin
         nextchar;
         expression(tree);
         skip(')');
      end
   end;

   procedure term(var tree:Ptree);
   var
      t:Ptree;
   begin
      factor(tree);
      while isNext(' and ') do begin
         new(t);
         t.kind:=_and;
         t.pleft:=tree;
         tree:=t;
         skip(' and ');
         factor(tree.pright);
      end;
   end;

   procedure complex_expression(var tree:Ptree);
   var
      t:Ptree;
   begin
      term(tree);
      while isNext(' or ') do begin
         new(t);
         t.kind:=_or;
         t.pleft:=tree;
         tree:=t;
         skip(' or ');
         term(tree.pright);
      end;
   end;

   procedure comparison(var tree:Ptree);
   begin
      new(tree);
      tree.kind:=cmp;
      if not (c in ['a'..'z']) then begin
         error('letter expected');
      end;
      tree.cleft:=c;
      nextchar;
      if c='<' then begin
         nextchar;
         if c='=' then begin
            nextchar;
            tree.sign:='<=';
            tree.antisign:='>';
         end
         else if c='>' then begin
            nextchar;
            tree.sign:='<>';
            tree.antisign:='=';
         end
         else begin
            tree.sign:='<';
            tree.antisign:='>=';
         end;
      end
      else if c='>' then begin
         nextchar;
         if c='=' then begin
            nextchar;
            tree.sign:='>=';
            tree.antisign:='<';
         end
         else begin
            tree.sign:='>';
            tree.antisign:='<=';
         end;
      end
      else if c='=' then begin
         nextchar;
         tree.sign:='=';
         tree.antisign:='<>';
      end
      else begin
         error('comparison sign expected');
      end;
      
      if not (c in ['a'..'z']) then begin
         error('letter expected');
      end;
      tree.cright:=c;
      nextchar;
   end;

   procedure expression(var tree:Ptree);
   begin
      if isNext('not ') or isNext('(') then begin
         complex_expression(tree);
      end
      else begin
         comparison(tree);
      end;
   end;

   procedure if_statement(var tree:Ptree);
   begin
      skip('if ');
      expression(tree);
      skip(' then something;');
      if not isEOT then begin
         error('EOT expected');
      end;
   end;

var
   labelId:char;

   procedure getLabel(var id:char);
   begin
      id:=labelId;
      inc(labelId);
   end;

var
   lines:array[1..100]of string[30];
   nLines:integer;

   procedure genLine(s:string);
   begin
      inc(nLines);
      lines[nLines]:=s;
   end;

   procedure RecFalseAfter(tree:Ptree;true_label,false_label:char);forward;

   procedure RecTrueAfter(tree:Ptree;true_label,false_label:char);
   var
      mid_label:char;
   begin
      case tree.kind of
      cmp:begin
         genLine('   if '+tree.cleft+tree.antisign+tree.cright+' then goto '+false_label+';');
      end;
      _and:begin
         getLabel(mid_label);
         RecTrueAfter(tree.pleft,mid_label,false_label);
         genLine(mid_label+':');
         RecTrueAfter(tree.pright,true_label,false_label);
      end;
      _or:begin
         getLabel(mid_label);
         RecFalseAfter(tree.pleft,true_label,mid_label);
         genLine(mid_label+':');
         RecTrueAfter(tree.pright,true_label,false_label);
      end;
      _not:begin
         RecFalseAfter(tree.pexpr,false_label,true_label);
      end;
      else
         error('RecTrueAfter');
      end;
   end;

   procedure RecFalseAfter(tree:Ptree;true_label,false_label:char);
   var
      mid_label:char;
   begin
      case tree.kind of
      cmp:begin
         genLine('   if '+tree.cleft+tree.sign+tree.cright+' then goto '+true_label+';');
      end;
      _and:begin
         getLabel(mid_label);
         RecTrueAfter(tree.pleft,mid_label,false_label);
         genLine(mid_label+':');
         RecFalseAfter(tree.pright,true_label,false_label);
      end;
      _or:begin
         getLabel(mid_label);
         RecFalseAfter(tree.pleft,true_label,mid_label);
         genLine(mid_label+':');
         RecFalseAfter(tree.pright,true_label,false_label);
      end;
      _not:begin
         RecTrueAfter(tree.pexpr,false_label,true_label);
      end;
      else
         error('RecFalseAfter');
      end;
   end;

   procedure RemoveUnusedLabels;
   var
      used:array['A'..'Z']of boolean;
      c:char;
      i,j:integer;
   begin
      for c:='A' to 'Z' do begin
         used[c]:=false;
      end;
      for i:=1 to nLines do begin
         if lines[i][1]=' ' then begin
            used[lines[i][length(lines[i])-1]]:=true;
         end;
      end;
      j:=0;
      for i:=1 to nLines do begin
         if (lines[i][1]=' ')or used[lines[i][1]] then begin
            inc(j);
            lines[j]:=lines[i];
         end;
      end;
      nLines:=j;
   end;

   procedure RenameLabel(old:char;new:string);
   var
      i,j:integer;
   begin
      for i:=1 to nLines do begin
         j:=1;
         while j<=length(lines[i]) do begin
            if lines[i][j]=old then begin
               lines[i]:=copy(lines[i],1,j-1)+new+copy(lines[i],j+1,1);
            end
            else begin
               inc(j);
            end;
         end;
      end;
   end;

   function FindOldLabel(var old:char):boolean;
   var
      i:integer;
   begin
      for i:=1 to nLines do begin
         if lines[i][1] in ['A'..'Z'] then begin
            old:=lines[i][1];
            FindOldLabel:=true;
            exit;
         end;
      end;
      FindOldLabel:=false;
   end;

   procedure RenameLabels;
   var
      old:char;
      new:string[2];
   begin
      new:='00';
      while true do begin
         if not FindOldLabel(old) then begin
            break;
         end;
         if new[2]='9' then begin
            new[2]:='0';
            inc(new[1]);
         end
         else begin
            inc(new[2]);
         end;
         RenameLabel(old,new);
      end;
   end;

   procedure show;
   var
      i:integer;
   begin
      for i:=1 to nLines do begin
         writeln(lines[i]);
      end;
   end;

var
   tree:Ptree;
begin
//   assign(input,'input.txt');
   reset(input);
//   assign(output,'output.txt');
   rewrite(output);
   readln(s);
   pos:=0;
   nextchar;
   if_statement(tree);
   labelId:='A';
   nLines:=0;
   RecTrueAfter(tree,'Y','Z');
   RemoveUnusedLabels;
   genLine('Y:');
   genLine('   something;');
   genLine('Z:');
   RenameLabel('Y','true');
   RenameLabel('Z','false');
   RenameLabels;
   show;
end.