static void solve ( ) {
  int x = ni ( ) , y = ni ( ) ;
  int n = ni ( ) ;
  int k = 0 ;
  if ( ( n ) % 3 == 0 ) {
    k = y - x ;
    if ( n % 2 == 0 ) {
      k = - k ;
    }
  }
  else if ( ( n + 1 ) % 3 == 0 ) {
    k = y ;
    if ( ( n + 1 ) % 2 == 0 ) {
      k = - k ;
    }
  }
  else if ( ( n + 2 ) % 3 == 0 ) {
    k = x ;
    if ( ( n + 2 ) % 2 == 0 ) {
      k = - k ;
    }
  }
  if ( k >= 0 ) {
    out ( k % MOD ) ;
  }
  else {
    if ( k == - MOD ) {
      out ( "0" ) ;
    }
    else {
      k = k % MOD ;
      out ( k + MOD ) ;
    }
  }
}

static void solve ( ) { int x = ni ( ) , y = ni ( ) ; int n = ni ( ) ; int k = 0 ; if ( ( n ) % 3 == 0 ) { k = y - x ; if ( n % 2 == 0 ) { k = - k ; } } else if ( ( n + 1 ) % 3 == 0 ) { k = y ; if ( ( n + 1 ) % 2 == 0 ) { k = - k ; } } else if ( ( n + 2 ) % 3 == 0 ) { k = x ; if ( ( n + 2 ) % 2 == 0 ) { k = - k ; } } if ( k >= 0 ) { out ( k % MOD ) ; } else { if ( k == - MOD ) { out ( "0" ) ; } else { k = k % MOD ; out ( k + MOD ) ; } } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (identifier)) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (identifier))))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (identifier))))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (identifier)))))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (identifier)))) consequence: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (string_literal))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))))))))