//这题真恶心
#include <iostream>
#include <cstring>

using namespace std;

const int N = 1005;
int a[N], s[5], T, n, flag, f[5];
double sb;

void work() {
    int cnt = 0;
    for (int i = 1; i <= n; i ++) {
        if (a[i] % 5 == 0 && a[i] % 2 == 0)
            s[0] += a[i], f[0] = 1;
        if (a[i] % 5 == 1) {
            if (flag == 0)
                s[1] += a[i], f[1] = 1, flag = 1;
            else 
                s[1] -= a[i], f[1] = 1, flag = 0;
        }
        if (a[i] % 5 == 2)
            s[2] ++, f[2] = 1;
        if (a[i] % 5 == 3)
            s[3] += a[i], f[3] = 1, cnt ++;
        if (a[i] % 5 == 4)
            s[4] = max(s[4], a[i]), f[4] = 1;
    }
    sb = s[3] * 1.0 / cnt;
}

int main() {
    cin >> T;
    while (T --) {
        flag = 0;
        memset(s, 0, sizeof s);
        memset(f, 0, sizeof f);
        s[4] = -0x3f3f3f3f;
        cin >> n;
        for (int i = 1; i <= n; i ++)
            cin >> a[i];
        work();
        for (int i = 0; i <= 2; i ++)
            if (f[i]) cout << s[i] << " ";
            else cout << "N" << " ";
        if (f[3]) printf("%.1lf ", sb);
        else cout << "N" << " ";
        if (f[4]) cout << s[4] << " ";
        else cout << "N" << " ";
        cout << endl;
    }
    return 0;
}