#pragma warning(disable:4996) #include<iostream> #include<stdio.h> #include<queue> #include<string.h> #include<set> #include<map> #include<string> #include<stack> #include<cmath> #include<iomanip> #include<algorithm> #include<stdlib.h> using namespace std; #define LL long long bool ok(LL x){ int e, o; e = o = 0; int now = 0; while (x > 0){ if (now == 0) o += x % 10; else e += x % 10; now = 1 - now; x /= 10; } o = o - e; if (o == 3) return false; while (o < 0) o += 11;//注意这里负数要先加11到正数为止,不然负数mod11 还是负数的 if (o % 11 == 3) return true; return false; } LL go(LL l, LL r){ for (LL i = l; i <= r; i++){ if (ok(i)) return i;//如果遇到一个值,差值为。。。-8,14,25.。。且mod 11 为3的,直接return } return -1;//没有找到,输出-1 } int main() { //freopen("aaa.txt", "r", stdin); //freopen("bbb.txt","w",stdout); int T; LL l, r; cin >> T; while (T--){ cin >> l >> r; LL ans = go(l,r); cout << ans << endl; } //while (1); return 0; }