text: first); } int main() { for (int i = (1); i <= (100000); i++) { rev[i] = calc_rev(i); } for (int i = (1); i <= (100000); i++) { lucky[a_reva(i)].push_back(i); } pair<int, int> ans = make_pair(-1, -1); long long ans_fact = ((long long)(1001001001) * (1001001001)); int maxx = in(); int maxy = in(); int w = in(); int bar = maxy; int ltickets = 0; for (int x = (1); x <= (maxx); x++) { vector<int> hoge = lucky[invert_pint(a_reva(x))]; int ind = distance(hoge.begin(), upper_bound(hoge.begin(), hoge.end(), bar)); ltickets += ind; while (ltickets >= w) { if ((long long)x * bar < ans_fact) { ans = make_pair(x, bar); ans_fact = (long long)x * bar; } vector<int> fuga = lucky[invert_pint(a_reva(bar))]; int ind2 = distance(fuga.begin(), upper_bound(fuga.begin(), fuga.end(), x)); ltickets -= ind2; bar--; } } if (ans.first == -1) { puts("-1"); } else { printf("%d %d\n", ans.first, ans.second); } return 0; }