public static void main ( String [ ] args ) {
  Scanner console = new Scanner ( System . in ) ;
  int n = console . nextInt ( ) ;
  int [ ] pArr = new int [ n ] ;
  int secN = 1 , lsecN = 0 , beforeN = 0 , lbeforeN = 0 , i , j ;
  Hashtable < Integer , Integer > hashtableF = new Hashtable < > ( ) ;
  Hashtable < Integer , Integer > hashtableB = new Hashtable < > ( ) ;
  while ( n -- > 0 ) {
    i = console . nextInt ( ) ;
    j = console . nextInt ( ) ;
    hashtableF . put ( i , j ) ;
    hashtableB . put ( j , i ) ;
  }
  for ( Map . Entry < Integer , Integer > entry : hashtableF . entrySet ( ) ) {
    if ( ! hashtableB . containsKey ( entry . getKey ( ) ) ) {
      lbeforeN = entry . getKey ( ) ;
      pArr [ lsecN ] = lbeforeN ;
      lsecN += 2 ;
      break ;
    }
  }
  for ( int x = 0 ;
  x <= pArr . length - 1 ;
  x += 2 ) {
    if ( lsecN <= pArr . length - 1 ) {
      pArr [ lsecN ] = hashtableF . get ( lbeforeN ) ;
      lbeforeN = pArr [ lsecN ] ;
    }
    if ( secN <= pArr . length - 1 ) {
      pArr [ secN ] = hashtableF . get ( beforeN ) ;
      beforeN = pArr [ secN ] ;
    }
    secN += 2 ;
    lsecN += 2 ;
    System . out . print ( pArr [ x ] ) ;
    if ( x + 1 <= pArr . length - 1 ) {
      System . out . print ( " " + pArr [ x + 1 ] ) ;
    }
    if ( x != pArr . length - 1 ) {
      System . out . print ( " " ) ;
    }
  }
}

public static void main ( String [ ] args ) { Scanner console = new Scanner ( System . in ) ; int n = console . nextInt ( ) ; int [ ] pArr = new int [ n ] ; int secN = 1 , lsecN = 0 , beforeN = 0 , lbeforeN = 0 , i , j ; Hashtable < Integer , Integer > hashtableF = new Hashtable < > ( ) ; Hashtable < Integer , Integer > hashtableB = new Hashtable < > ( ) ; while ( n -- > 0 ) { i = console . nextInt ( ) ; j = console . nextInt ( ) ; hashtableF . put ( i , j ) ; hashtableB . put ( j , i ) ; } for ( Map . Entry < Integer , Integer > entry : hashtableF . entrySet ( ) ) { if ( ! hashtableB . containsKey ( entry . getKey ( ) ) ) { lbeforeN = entry . getKey ( ) ; pArr [ lsecN ] = lbeforeN ; lsecN += 2 ; break ; } } for ( int x = 0 ; x <= pArr . length - 1 ; x += 2 ) { if ( lsecN <= pArr . length - 1 ) { pArr [ lsecN ] = hashtableF . get ( lbeforeN ) ; lbeforeN = pArr [ lsecN ] ; } if ( secN <= pArr . length - 1 ) { pArr [ secN ] = hashtableF . get ( beforeN ) ; beforeN = pArr [ secN ] ; } secN += 2 ; lsecN += 2 ; System . out . print ( pArr [ x ] ) ; if ( x + 1 <= pArr . length - 1 ) { System . out . print ( " ▁ " + pArr [ x + 1 ] ) ; } if ( x != pArr . length - 1 ) { System . out . print ( " ▁ " ) ; } } }
(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)))) (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 (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (while_statement condition: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))))) (enhanced_for_statement type: (generic_type (scoped_type_identifier (type_identifier) (type_identifier)) (type_arguments (type_identifier) (type_identifier))) name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (break_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: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) update: (assignment_expression left: (identifier) right: (decimal_integer_literal)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (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: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))))))))