public static void main ( String args [ ] ) throws Exception {
  Scanner in = new Scanner ( System . in ) ;
  int t = in . nextInt ( ) ;
  for ( int tt = 1 ;
  tt <= t ;
  tt ++ ) {
    int h = in . nextInt ( ) ;
    int w = in . nextInt ( ) ;
    int r = in . nextInt ( ) ;
    int [ ] a = new int [ r ] , b = new int [ r ] ;
    boolean [ ] [ ] f = new boolean [ h + 1 ] [ w + 1 ] ;
    for ( int i = 0 ;
    i < r ;
    i ++ ) {
      a [ i ] = in . nextInt ( ) ;
      b [ i ] = in . nextInt ( ) ;
      f [ a [ i ] ] [ b [ i ] ] = true ;
    };
    int [ ] [ ] D = new int [ h + 1 ] [ w + 1 ] ;
    D [ 1 ] [ 1 ] = 1 ;
    for ( int i = 2 ;
    i <= h ;
    i ++ ) for ( int j = 2 ;
    j <= w ;
    j ++ ) if ( ! f [ i ] [ j ] ) D [ i ] [ j ] += ( D [ i - 2 ] [ j - 1 ] + D [ i - 1 ] [ j - 2 ] ) % 10007 ;
    System . out . println ( "Case #" + tt + ": " + D [ h ] [ w ] ) ;
  };
}

public static void main ( String args [ ] ) throws Exception { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; for ( int tt = 1 ; tt <= t ; tt ++ ) { int h = in . nextInt ( ) ; int w = in . nextInt ( ) ; int r = in . nextInt ( ) ; int [ ] a = new int [ r ] , b = new int [ r ] ; boolean [ ] [ ] f = new boolean [ h + 1 ] [ w + 1 ] ; for ( int i = 0 ; i < r ; i ++ ) { a [ i ] = in . nextInt ( ) ; b [ i ] = in . nextInt ( ) ; f [ a [ i ] ] [ b [ i ] ] = true ; } ; int [ ] [ ] D = new int [ h + 1 ] [ w + 1 ] ; D [ 1 ] [ 1 ] = 1 ; for ( int i = 2 ; i <= h ; i ++ ) for ( int j = 2 ; j <= w ; j ++ ) if ( ! f [ i ] [ j ] ) D [ i ] [ j ] += ( D [ i - 2 ] [ j - 1 ] + D [ i - 1 ] [ j - 2 ] ) % 10007 ; System . out . println ( " Case ▁ # " + tt + " : ▁ " + D [ h ] [ w ] ) ; } ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) (throws (type_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)))) (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: (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 (identifier)))) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (array_type element: (boolean_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal))) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (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: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))) index: (array_access array: (identifier) index: (identifier))) right: (true))))) (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))) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (decimal_integer_literal)) index: (decimal_integer_literal)) right: (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: (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: (if_statement condition: (parenthesized_expression (unary_expression operand: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)))) consequence: (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (decimal_integer_literal))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))))))))