func_code_string: #include <bits/stdc++.h>   std::map<std::string, std::string> opcodes;   std::string next(std::string s) {     std::string res = s;     res[res.size() - 1]++;     for (int i = (int)res.size() - 1; i >= 0; i--) {       if (res[i] >  f ) {         res[i] =  a ;         res[i - 1]++;       }     }     return res;   }   int check(std::string s) {     if (s.size() == 1) return !!(s[0] ==  a );     std::string f = s.substr(0, 2);     s.erase(0, 2);     auto it = opcodes.find(f);     if (it == opcodes.end()) return 0;     s = it->second + s;     return check(s);   }   int main() {     std::ios_base::sync_with_stdio(0);     int n, q;     std::cin >> n >> q;     std::string str =   , fff, a, b;     for (int i = 0; i < n; i++) str.push_back( a );     for (int i = 0; i < n; i++) fff.push_back( f );     for (int i = 0; i < q; i++) {       std::cin >> a >> b;       opcodes[a] = b;     }     int ans = 0;     while (true) {       ans += check(str);       if (str == fff)         break;       else         str = next(str);     }     std::cout << ans << std::endl;     return 0;   }   