#include <iostream>
#include <algorithm>

using namespace std;

void analyze_digits(long long n, int &min_d, int &max_d, int &count_odd, int &count_even) {
    min_d = 9;
    max_d = 0;
    count_odd = 0;
    count_even = 0;

    while (n > 0) {
        int d = n % 10;
        min_d = min(min_d, d);
        max_d = max(max_d, d);

        if (d % 2 == 0) {
            count_even++;
        } else {
            count_odd++;
        }

        n /= 10;
    }
}

void solve() {
    long long n;
    cin >> n;

    int min_d, max_d, count_odd, count_even;
    analyze_digits(n, min_d, max_d, count_odd, count_even);

    if ((max_d - min_d) % 2 == 0 && count_odd == count_even) {
        cout << "YASS " << min_d << " " << max_d << " " << count_odd << " " << count_even << "\n";
    } else {
        cout << "NO\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    if (cin >> t) {
        while (t--) {
            solve();
        }
    }

    return 0;
}