{10:12 - 15:22 (с перерывами общей продолжительностью около 20 минут)}

type

  PNode = ^TNode;
  TNode = record
    leaf: boolean;
    a,b: char;
    op: string[3];
    left,right,next,parent,uplink: PNode;
    lb: integer;
    lvalue, rvalue: shortint;
  end;

var
  root, p_true, p_false: PNode;
  leaves: PNode;
  cur_leaf: PNode;
  s: string;
  i: integer;

procedure expression(var i: integer; var p: pnode); forward;

procedure Mnoz(var i: integer; var p: pnode);
var
  p1: PNode;
begin
  if Copy(s,i,3)='not' then
  begin
    i:=i+4;
    Mnoz(i,p1);
    new(p); fillchar(p^,sizeof(TNode),0); p^.lvalue := -1; p^.rvalue := -1;
    p^.op := 'not';
    p^.left := p1;
    p1^.parent := p;
  end else
  begin
    inc(i);
    expression(i,p);
    inc(i);
  end;    
end;

procedure slag(var i: integer; var p: pnode);
var
  p1,p2: PNode;
begin
  Mnoz(i,p1);
  if copy(s,i,5)<>' and ' then
  begin
    p:=p1;
    exit;
  end;
  while copy(s,i,5)=' and ' do
  begin
    i:=i+5;
    Mnoz(i,p2);
    new(p); fillchar(p^,sizeof(TNode),0); p^.lvalue := -1; p^.rvalue := -1;
    p^.left := p1; p1^.parent := p;
    p^.right := p2; p2^.parent := p;
    p^.op := 'and';
    p1 := p; {root will be left son of new root}
  end;
end;

procedure SostavnExpr(var i: integer; var p: pnode);
var
  p1,p2: PNode;
begin
  Slag(i,p1);
  if copy(s,i,4)<>' or ' then
  begin
    p:=p1; exit;
  end;
  while copy(s,i,4)=' or ' do
  begin
    i:=i+4;
    Slag(i,p2);
    new(p); fillchar(p^,sizeof(TNode),0); p^.lvalue := -1; p^.rvalue := -1;
    p^.left := p1; p1^.parent := p;
    p^.right := p2; p2^.parent := p;
    p^.op := 'or';
    p1 := p; {root will be left son of new root}
  end;
end;

procedure expression(var i: integer; var p: pnode);
begin
  if (s[i] in ['a'..'z']) and not (s[i+1] in ['a'..'z']) then
  begin
    new(p); fillchar(p^,sizeof(TNode),0); p^.lvalue := -1; p^.rvalue := -1;
    p^.a := s[i];
    p^.leaf := true;
    if (s[i+2] in ['a'..'z'])then
    begin
      p^.b := s[i+2];
      p^.op := s[i+1];
      i:=i+3;
    end else
    begin
      p^.b := s[i+3];
      p^.op := s[i+1]+s[i+2];
      i := i + 4;
    end;
    if cur_leaf=nil then
    begin
      leaves:=p;
      cur_leaf:=p;
    end else
    begin
      cur_leaf^.next := p;
      cur_leaf := p;
    end;
  end else
    SostavnExpr(i,p);
end;

{tests}

function inverse(op: string):string;
begin
   if op='<' then inverse:='>=' else
   if op='>' then inverse:='<=' else
   if op='=' then inverse:='<>' else
   if op='<>' then inverse:='=' else
   if op='<=' then inverse:='>' else
   if op='>=' then inverse:='<';
end;

function get_path_len(p: PNode; v: integer; var upnode: PNode): integer;
var
  d: Integer;
  t: PNode;
begin
  d := 0;
  while p^.parent<>nil do
  begin

    inc(d);
    t := p^.parent;
    if t^.op='not' then
      v := 1-v
    else
    begin
       if t^.left=p then
       begin

         {we from left}
         if (t^.op='or') and (v=1) then v:=1 else
         if (t^.op='and') and (v=0) then v:=0 else
         begin
           upnode := t;
           get_path_len := d;
           exit;
         end;

       end else
       begin

         {we from right}
         if (t^.op='or') and (v=1) then v:=1 else
         if (t^.op='or') and (t^.lvalue=1) then v:=1 else
         if (t^.op='or') and (t^.lvalue=0) and (v=0) then v:=0 else
         if (t^.op='and') and (v=0) then v:=0 else
         if (t^.op='and') and (t^.lvalue=0) then v:=0 else
         if (t^.op='and') and (t^.lvalue=1) and (v=1) then v:=1 else
         begin
           upnode := t;
           get_path_len := d;
           exit;
         end;
       end;
    end;

    p := t;

  end; {while}

  if v=1 then upnode := p_true else upnode := p_false;
  get_path_len := d+1;

end;

procedure make_known_up_values(p: PNode; v: integer);
var
  t: PNode;
begin
  while p^.parent<>nil do
  begin

    t := p^.parent;
    t^.lvalue := v;

    if t^.op='not' then
    begin
      v := 1-v;
    end
    else
    begin
       if t^.left=p then
       begin

         {we from left}
         if (t^.op='or') and (v=1) then v:=1 else
         if (t^.op='and') and (v=0) then v:=0 else
         begin
           exit;
         end;

       end else
       begin

         {we from right}
         if (t^.op='or') and (v=1) then v:=1 else
         if (t^.op='or') and (t^.lvalue=1) then v:=1 else
         if (t^.op='or') and (t^.lvalue=0) and (v=0) then v:=0 else
         if (t^.op='and') and (v=0) then v:=0 else
         if (t^.op='and') and (t^.lvalue=0) then v:=0 else
         if (t^.op='and') and (t^.lvalue=1) and (v=1) then v:=1 else
         begin
           exit;
         end;

       end;
    end;

    p := t;

  end; {while}

end;


procedure make_up_edge(p: PNode);
var
  d1,d2: integer;
  p1,p2: PNode;
begin
  {find value with longest path to root}
  d1 := get_path_len(p,0,p1);
  d2 := get_path_len(p,1,p2);
  if d1>=d2 then begin
    p^.uplink := p1;
    p1^.lb:=1;
    p^.lvalue := 1; {inverse}
    make_known_up_values(p,p^.lvalue);
  end else
  begin
    p^.uplink := p2;
    p2^.lb:=1;
    p^.lvalue := 0; {inverse}
    make_known_up_values(p, p^.lvalue);
  end;
end;

procedure make_up_edges;
var
  p: PNode;
begin
  p := leaves;
  while p<>nil do
  begin
    make_up_edge(p);
    p := p^.next;
  end;
end;

var
  lb_num: integer;

procedure make_labels(p: PNode);
begin
  if p=nil then exit;
  make_labels(p^.left);
  if p^.lb<>0 then
  begin
    inc(lb_num);
    p^.lb := lb_num;
  end;
  make_labels(p^.right);
end;

procedure _makeanswer(p: PNode);
begin

  if p=nil then exit;

  if p^.leaf then
  begin

    if p^.next=nil then
      if p^.uplink=p_true then
      begin
        p^.uplink := p_false;
        p^.lvalue := 1 - p^.lvalue;
      end;


    write('   if ',p^.a);
    if p^.lvalue=0 then write(p^.op) else write(inverse(p^.op));
    write(p^.b,' then goto ');
    if p^.uplink = p_true then writeln('true;') else
    if p^.uplink = p_false then writeln('false;') else
    begin
      if p^.uplink^.lb<10 then writeln('0',p^.uplink^.lb,';') else writeln(p^.uplink^.lb,';');
    end;

    exit;
  end;

  _makeanswer(p^.left);
  if (p^.lb<>0) then
    if p^.lb<10 then writeln('0',p^.lb,':') else writeln(p^.lb,':');
  _makeanswer(p^.right);
end;

procedure makeanswer;
begin
  _makeanswer(root);
  writeln('true:');
  writeln('   something;');
  writeln('false:');
end;

begin
///  assign(input,'input.txt'); reset(input);
//  assign(output,'output.txt'); rewrite(output);
  root := nil; leaves := nil; cur_leaf:=nil; lb_num := 0;

  new (p_true); fillchar(p_true^, sizeof(TNode), 0); p_true^.lvalue := -1; p_true^.rvalue := -1;
  new (p_false); fillchar(p_false^, sizeof(TNode), 0); p_false^.lvalue := -1; p_false^.rvalue := -1;

  readln(s);
  s := copy(s, 4, length(s) - 3 - length(' then something;'));
  i := 1;
  expression(i,root);
  make_up_edges;
  make_labels(root);
  makeanswer;

end.
