#define _CRT_SECURE_NO_DEPRECATE #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int MAXN = 1000000 + 10; struct node{ string str1; int len; }no[5]; bool cmp(const node& a, const node& b){ if (a.len == b.len){ for (int i = 0; i < a.len; i++){ if (a.str1[i] == b.str1[i])continue; else return a.str1[i] < b.str1[i]; } } return a.len < b.len; } string add(string s1, string s2){ if (s1 == ""&&s2 == "")return "0"; if (s1 == "") return s2; if (s2 == "")return s1; string max = s2, min = s1; if (s1.length() > s2.length()){ max = s1; min = s2; } int a = max.length() - 1, b = min.length() - 1; for (int i = b; i >= 0; i--) max[a--] += min[i] - '0'; for (int j = max.length() - 1; j > 0; j--){ if (max[j] > '9'){ max[j] = max[j] - 10; max[j - 1] += 1; } } if (max[0] > '9'){ max[0] -= 10; max = '1' + max; } return max; } bool judge(string str1, string str2){ int len1 = str1.length(); int len2 = str2.length(); int flag = 0; if (len1 > len2)return true; else if (len1 < len2)return false; else{ for (int i = 0; i < len1; i++){ if (str1[i] == str2[i])continue; if (str1[i] < str2[i]){ flag = 1; break; } if (str1[i] > str2[i]){ flag = 2; break; } } if (flag == 1)return false; if (flag == 2)return true; } } int main(){ int T; scanf("%d", &T); int flag; while (T--) { flag = 0; for (int i = 0; i < 4; i++){ cin >> no[i].str1; no[i].len = no[i].str1.length(); if (no[i].str1 == "0")flag = 1; } sort(no, no + 4, cmp); string tmp1 = add(no[0].str1, no[1].str1); string tmp2 = add(tmp1, no[2].str1); bool bb = judge(tmp2, no[3].str1); if (bb && flag == 0)printf("Yes\n"); else printf("No\n"); } return 0; }