{"raw_statement":[{"iden":"problem statement","content":"Find the largest integer that can be formed with exactly $N$ matchsticks, under the following conditions:\n\n*   Every digit in the integer must be one of the digits $A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9)$.\n*   The number of matchsticks used to form digits $1, 2, 3, 4, 5, 6, 7, 8, 9$ should be $2, 5, 5, 4, 5, 6, 3, 7, 6$, respectively."},{"iden":"constraints","content":"*   All values in input are integers.\n*   $2 \\leq N \\leq 10^4$\n*   $1 \\leq M \\leq 9$\n*   $1 \\leq A_i \\leq 9$\n*   $A_i$ are all different.\n*   There exists an integer that can be formed by exactly $N$ matchsticks under the conditions."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$\n$A_1$ $A_2$ $...$ $A_M$"},{"iden":"sample input 1","content":"20 4\n3 7 8 4"},{"iden":"sample output 1","content":"777773\n\nThe integer $777773$ can be formed with $3 + 3 + 3 + 3 + 3 + 5 = 20$ matchsticks, and this is the largest integer that can be formed by $20$ matchsticks under the conditions."},{"iden":"sample input 2","content":"101 9\n9 8 7 6 5 4 3 2 1"},{"iden":"sample output 2","content":"71111111111111111111111111111111111111111111111111\n\nThe output may not fit into a $64$\\-bit integer type."},{"iden":"sample input 3","content":"15 3\n5 4 6"},{"iden":"sample output 3","content":"654"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}