func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   int cost[2005];   bool have[2005][3];   int dp[2003][10];   int solve(int i, int vits) {     if (i >= n) {       if (vits == 7) return 0;       return 1e9;     }     int &ret = dp[i][vits];     if (ret + 1) return ret;     int sol1 = 0, sol2 = 0;     sol1 = solve(i + 1, vits);     sol2 = cost[i] + solve(i + 1, vits | (have[i][0] | (2 * have[i][1]) |                                           (4 * have[i][2])));     return ret = min(sol1, sol2);   }   int main() {     ios_base::sync_with_stdio(false);     memset(dp, -1, sizeof(dp));     cin >> n;     for (int i = 0; i < n; i++) {       cin >> cost[i];       string s;       cin >> s;       for (auto x : s) {         if (x ==  A ) have[i][0] = true;         if (x ==  B ) have[i][1] = true;         if (x ==  C ) have[i][2] = true;       }     }     int res = solve(0, 0);     if (res > 7e8) res = -1;     cout << res <<   n ;     return 0;   }   