func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   template <class T, class U>   using Pa = pair<T, U>;   template <class T>   using vec = vector<T>;   template <class T>   using vvec = vector<vec<T>>;   bool chmax(int &a, int b) {     if (a < b) {       a = b;       return true;     }     return false;   }   vec<string> A = { 1110111 ,  0010010 ,  1011101 ,  1011011 ,  0111010 ,                     1101011 ,  1101111 ,  1010010 ,  1111111 ,  1111011 };   int dp[2010][2010] = {};   int pre[2010][2010] = {};   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int N, K;     cin >> N >> K;     vec<string> S(N);     for (int i = 0; i < N; i++) cin >> S[i];     int M = 7;     auto calc = [&](string T, int num) {       string B = A[num];       bool ok = true;       int c = 0;       for (int i = 0; i < M; i++) {         if (T[i] ==  1  && B[i] ==  0 ) ok = false;         if (T[i] ==  0  && B[i] ==  1 ) c++;       }       if (!ok)         return -1;       else         return c;     };     for (int i = 0; i <= N; i++)       for (int k = 0; k <= K; k++) dp[i][k] = -1;     dp[0][0] = 0;     for (int i = 0; i < N; i++)       for (int j = 0; j <= K; j++)         if (dp[i][j] != -1) {           for (int n = 0; n < 10; n++) {             int c = calc(S[N - 1 - i], n);             if (c == -1) continue;             if (j + c <= K) {               if (chmax(dp[i + 1][j + c], n)) {                 pre[i + 1][j + c] = j;               }             }           }         }     if (dp[N][K] == -1) {       cout << -1 <<   n ;       return 0;     }     string ans =   ;     int now = K;     for (int i = N - 1; i >= 0; i--) {       char c =  0  + dp[i + 1][now];       ans += c;       now = pre[i + 1][now];     }     cout << ans <<   n ;   }   