3
void dfs(string &s, string &small, int a, int b, unordered_map<string, string> &memo) {4
if (memo.count(s)) return;5
string res = s, str = res;7
rotate(str.begin(), str.begin() + b, str.end()); // rotate current string8
dfs(str, small, a, b, memo);9
if (memo[str] < res) res = memo[str];11
for (int i = 0; i < 9; i++) { // or add it12
for (int j = 1; j < s.length(); j += 2) s[j] = '0' + ((s[j] - '0') + a) % 10;14
dfs(s, small, a, b, memo);16
if (small > res) small = res;19
string findLexSmallestString(string s, int a, int b) {20
unordered_map<string, string> memo;22
dfs(s, res, a, b, memo);