public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int a = sc . nextInt ( ) ;
  int b = sc . nextInt ( ) ;
  int q = sc . nextInt ( ) ;
  long [ ] a1 = new long [ a + 2 ] ;
  long [ ] b1 = new long [ b + 2 ] ;
  a1 [ 0 ] = b1 [ 0 ] = Long . MIN_VALUE ;
  a1 [ a + 1 ] = b1 [ b + 1 ] = Long . MAX_VALUE / 2 ;
  long [ ] ans1 = new long [ q ] ;
  for ( int i = 1 ;
  i <= a ;
  i ++ ) {
    a1 [ i ] = sc . nextLong ( ) ;
  }
  for ( int i = 1 ;
  i <= b ;
  i ++ ) {
    b1 [ i ] = sc . nextLong ( ) ;
  }
  for ( int k = 0 ;
  k < q ;
  k ++ ) {
    long x = sc . nextLong ( ) ;
    long ans = Long . MAX_VALUE ;
    int idxa = - Arrays . binarySearch ( a1 , x ) - 1 ;
    int [ ] a2 = {
      idxa , ( idxa == 1 ) ? a + 1 : idxa - 1 };
      int idxb = - Arrays . binarySearch ( b1 , x ) - 1 ;
      int [ ] b2 = {
        idxb , ( idxb == 1 ) ? b + 1 : idxb - 1 };
        for ( int i : a2 ) {
          for ( int j : b2 ) {
            ans = Math . min ( ans , Math . abs ( a1 [ i ] - x ) + Math . abs ( a1 [ i ] - b1 [ j ] ) ) ;
            ans = Math . min ( ans , Math . abs ( b1 [ j ] - x ) + Math . abs ( a1 [ i ] - b1 [ j ] ) ) ;
          }
        }
        ans1 [ k ] = ans ;
      }
      for ( int i = 0 ;
      i < q ;
      i ++ ) {
        System . out . println ( ans1 [ i ] ) ;
      }
    }
    
public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; long [ ] a1 = new long [ a + 2 ] ; long [ ] b1 = new long [ b + 2 ] ; a1 [ 0 ] = b1 [ 0 ] = Long . MIN_VALUE ; a1 [ a + 1 ] = b1 [ b + 1 ] = Long . MAX_VALUE / 2 ; long [ ] ans1 = new long [ q ] ; for ( int i = 1 ; i <= a ; i ++ ) { a1 [ i ] = sc . nextLong ( ) ; } for ( int i = 1 ; i <= b ; i ++ ) { b1 [ i ] = sc . nextLong ( ) ; } for ( int k = 0 ; k < q ; k ++ ) { long x = sc . nextLong ( ) ; long ans = Long . MAX_VALUE ; int idxa = - Arrays . binarySearch ( a1 , x ) - 1 ; int [ ] a2 = { idxa , ( idxa == 1 ) ? a + 1 : idxa - 1 } ; int idxb = - Arrays . binarySearch ( b1 , x ) - 1 ; int [ ] b2 = { idxb , ( idxb == 1 ) ? b + 1 : idxb - 1 } ; for ( int i : a2 ) { for ( int j : b2 ) { ans = Math . min ( ans , Math . abs ( a1 [ i ] - x ) + Math . abs ( a1 [ i ] - b1 [ j ] ) ) ; ans = Math . min ( ans , Math . abs ( b1 [ j ] - x ) + Math . abs ( a1 [ i ] - b1 [ j ] ) ) ; } } ans1 [ k ] = ans ; } for ( int i = 0 ; i < q ; i ++ ) { System . out . println ( ans1 [ i ] ) ; } }
(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: (integral_type) 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: (identifier) right: (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 (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (field_access object: (identifier) field: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (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 (identifier))))) (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: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (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: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (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 (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: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))) right: (decimal_integer_literal)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_initializer (identifier) (ternary_expression condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (binary_expression left: (identifier) right: (decimal_integer_literal)) alternative: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))) right: (decimal_integer_literal)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_initializer (identifier) (ternary_expression condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (binary_expression left: (identifier) right: (decimal_integer_literal)) alternative: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))))))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))))))))))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))) (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 (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))))))