public static void main ( String [ ] args ) {
  int tests ;
  Scanner scanner = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ;
  tests = scanner . nextInt ( ) ;
  for ( int z = 1 ;
  z <= tests ;
  z ++ ) {
    BigInteger L = scanner . nextBigInteger ( ) ;
    int ile = scanner . nextInt ( ) ;
    Vector < Integer > roznice = new Vector < Integer > ( ) ;
    while ( ile -- > 0 ) {
      roznice . add ( scanner . nextInt ( ) ) ;
    }
    Collections . sort ( roznice ) ;
    int last = roznice . lastElement ( ) ;
    roznice . removeElement ( last ) ;
    Vector < Integer > minodl = new Vector < Integer > ( last ) ;
    minodl . setSize ( last ) ;
    for ( int i = 0 ;
    i < minodl . size ( ) ;
    i ++ ) minodl . setElementAt ( Integer . MAX_VALUE , i ) ;
    Queue < Integer > q = new LinkedList < Integer > ( ) ;
    minodl . setElementAt ( 0 , 0 ) ;
    q . add ( 0 ) ;
    while ( q . isEmpty ( ) == false ) {
      Integer x = q . remove ( ) ;
      for ( Integer i : roznice ) {
        int newx = x + i ;
        int odl = minodl . elementAt ( x ) + 1 ;
        while ( newx >= last ) {
          newx -= last ;
          odl -- ;
        }
        if ( minodl . elementAt ( newx ) > odl ) {
          minodl . setElementAt ( odl , newx ) ;
          q . add ( newx ) ;
        }
      }
    }
    System . out . printf ( "Case #%d: " , z ) ;
    BigInteger odleglosc = BigInteger . valueOf ( last ) ;
    BigInteger wynik = L . divide ( odleglosc ) ;
    Integer indeks = L . mod ( odleglosc ) . intValue ( ) ;
    BigInteger ileKoniec = BigInteger . valueOf ( minodl . elementAt ( indeks ) ) ;
    if ( ileKoniec . compareTo ( BigInteger . valueOf ( Integer . MAX_VALUE ) ) >= 0 ) {
      System . out . println ( "IMPOSSIBLE" ) ;
    }
    else {
      wynik = wynik . add ( ileKoniec ) ;
      System . out . println ( wynik ) ;
    }
  }
}

public static void main ( String [ ] args ) { int tests ; Scanner scanner = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; tests = scanner . nextInt ( ) ; for ( int z = 1 ; z <= tests ; z ++ ) { BigInteger L = scanner . nextBigInteger ( ) ; int ile = scanner . nextInt ( ) ; Vector < Integer > roznice = new Vector < Integer > ( ) ; while ( ile -- > 0 ) { roznice . add ( scanner . nextInt ( ) ) ; } Collections . sort ( roznice ) ; int last = roznice . lastElement ( ) ; roznice . removeElement ( last ) ; Vector < Integer > minodl = new Vector < Integer > ( last ) ; minodl . setSize ( last ) ; for ( int i = 0 ; i < minodl . size ( ) ; i ++ ) minodl . setElementAt ( Integer . MAX_VALUE , i ) ; Queue < Integer > q = new LinkedList < Integer > ( ) ; minodl . setElementAt ( 0 , 0 ) ; q . add ( 0 ) ; while ( q . isEmpty ( ) == false ) { Integer x = q . remove ( ) ; for ( Integer i : roznice ) { int newx = x + i ; int odl = minodl . elementAt ( x ) + 1 ; while ( newx >= last ) { newx -= last ; odl -- ; } if ( minodl . elementAt ( newx ) > odl ) { minodl . setElementAt ( odl , newx ) ; q . add ( newx ) ; } } } System . out . printf ( " Case ▁ # % d : ▁ " , z ) ; BigInteger odleglosc = BigInteger . valueOf ( last ) ; BigInteger wynik = L . divide ( odleglosc ) ; Integer indeks = L . mod ( odleglosc ) . intValue ( ) ; BigInteger ileKoniec = BigInteger . valueOf ( minodl . elementAt ( indeks ) ) ; if ( ileKoniec . compareTo ( BigInteger . valueOf ( Integer . MAX_VALUE ) ) >= 0 ) { System . out . println ( " IMPOSSIBLE " ) ; } else { wynik = wynik . add ( ileKoniec ) ; System . out . println ( wynik ) ; } } }
(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: (integral_type) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))))) (expression_statement (assignment_expression left: (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: (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: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (while_statement condition: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)) (identifier))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (false))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (enhanced_for_statement type: (type_identifier) name: (identifier) value: (identifier) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (identifier))) consequence: (block (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)))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal) (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))))))