public static void main ( String [ ] args ) {
  Scanner scanner = new Scanner ( System . in ) ;
  int t = scanner . nextInt ( ) ;
  while ( t -- > 0 ) {
    String st = scanner . next ( ) ;
    int size = st . length ( ) ;
    int [ ] ss = new int [ 2 * size ] ;
    int flag = 1 ;
    int j = 0 ;
    char [ ] a = new char [ 2 ] ;
    a [ 0 ] = 'a' ;
    a [ 1 ] = 'a' ;
    for ( int i = 0 ;
    i < size ;
    ++ i ) {
      if ( st . charAt ( i ) == '1' ) a [ 1 ] = 1 ;
      else if ( st . charAt ( i ) == '0' ) a [ 0 ] = 0 ;
    }
    if ( a [ 0 ] == 'a' || a [ 1 ] == 'a' ) {
      System . out . println ( st ) ;
      continue ;
    }
    for ( int i = 0 ;
    i < size ;
    ++ j ) {
      if ( flag == 1 ) {
        ss [ j ] = 1 ;
        if ( st . charAt ( i ) == '1' ) ++ i ;
      }
      else if ( flag == - 1 ) {
        ss [ j ] = 0 ;
        if ( st . charAt ( i ) == '0' ) ++ i ;
      }
      flag *= - 1 ;
    }
    int check = - 1 ;
    for ( int i = 0 ;
    i < j ;
    ++ i ) {
      check = ss [ i ] ;
      System . out . print ( ss [ i ] ) ;
    }
    if ( check == 1 ) System . out . print ( "0" ) ;
    System . out . print ( "\n" ) ;
  }
  scanner . close ( ) ;
}

public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; while ( t -- > 0 ) { String st = scanner . next ( ) ; int size = st . length ( ) ; int [ ] ss = new int [ 2 * size ] ; int flag = 1 ; int j = 0 ; char [ ] a = new char [ 2 ] ; a [ 0 ] = ' a ' ; a [ 1 ] = ' a ' ; for ( int i = 0 ; i < size ; ++ i ) { if ( st . charAt ( i ) == '1' ) a [ 1 ] = 1 ; else if ( st . charAt ( i ) == '0' ) a [ 0 ] = 0 ; } if ( a [ 0 ] == ' a ' || a [ 1 ] == ' a ' ) { System . out . println ( st ) ; continue ; } for ( int i = 0 ; i < size ; ++ j ) { if ( flag == 1 ) { ss [ j ] = 1 ; if ( st . charAt ( i ) == '1' ) ++ i ; } else if ( flag == - 1 ) { ss [ j ] = 0 ; if ( st . charAt ( i ) == '0' ) ++ i ; } flag *= - 1 ; } int check = - 1 ; for ( int i = 0 ; i < j ; ++ i ) { check = ss [ i ] ; System . out . print ( ss [ i ] ) ; } if ( check == 1 ) System . out . print ( "0" ) ; System . out . print ( " \n " ) ; } scanner . close ( ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (while_statement condition: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (decimal_integer_literal) right: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (character_literal))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (character_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (character_literal)) right: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (character_literal)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) (continue_statement))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (expression_statement (update_expression (identifier))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (expression_statement (update_expression (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))