#pragma comment(linker, "/STACK: 16777216")

#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl


using ll = long long;
using hll = __int128;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

template <typename T>
void freadT(T &x) {
    x = 0;
    char ch = _getchar_nolock();
    ll sign = 1;

    while (!isdigit(ch)) {
        if (ch == '-')
            sign *= -1;
        ch = _getchar_nolock();
    }

    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = _getchar_nolock();
    }

    x *= sign;
}

int fparse(string s, int start_indx) {
    int x = 0;

    while (isdigit(s[start_indx])) {
        x = x * 10 + s[start_indx] - '0';
        ++start_indx;
    }

    return x;
}

#define solvsh
//#define multi

#ifdef solvsh


map<pair<int, int>, ll> mp;

void solve() {
    int n;
    freadT(n);

    ll answr = 0;

    for (int i = 0; i < n; ++ i) {
        char ch = _getchar_nolock();
        while (!isdigit(ch)) {
            ch = _getchar_nolock();
        }

        ll x = 0;
        while (isdigit(ch)) {
            x = x * 10 + ch - '0';
            ch = _getchar_nolock();
        }
        ll y = 0;
        ll pw = 1;
        if (ch == '.') {

            ch = _getchar_nolock();
            while (isdigit(ch)) {
                y = y * 10 + ch - '0';
                ch = _getchar_nolock();
                pw *= 10;
            }
        }
        if (y == 0){
            answr --;
        }

        y += pw * x;

        while (pw % 5 == 0 && y % 5 == 0) {
            y /= 5;
            pw /= 5;
        }

        while (pw % 2 == 0 && y % 2 == 0) {
            y /= 2;
            pw /= 2;
        }
        int dx = 0;
        if (pw % 5 != 0) {
            while (y % 5 == 0) {
                y /= 5;
                ++dx;
            }
        } else {
            while (pw % 5 == 0) {
                pw /= 5;
                --dx;
            }
        }
        int dy = 0;
        if (pw % 2 != 0) {
            while (y % 2 == 0) {
                y /= 2;
                ++dy;
            }
        } else {
            while (pw % 2 == 0) {
                pw /= 2;
                --dy;
            }
        }
        if (dx > 9) dx = 9;
        if (dx < -9) dx = -9;
        if (dy > 9) dy = 9;
        if (dy < -9) dy = -9;
        mp[{dx, dy}]++;
    }

    for (int i = -9; i <= 9; ++ i) {
        for (int j = -9; j <= 9; ++j) {

            ll cnt = 0;

            for (int t = -i; t <= 9; ++t) {
                for (int k = -j; k <= 9; ++ k) {
                    if (mp[{i, j}] && mp[{t, k}]) {
                        cnt += mp[{i, j}] * mp[{t, k}];
                    }
                }
            }

            answr += cnt;
        }
    }

    cout << answr / 2 << '\n';

}


#else

void solve() {

}


#endif

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


void multisolve() {
//    prec();
    int t;
    freadT(t);
//    prec();
//    scanf("%d", &t);

    int i = 1;
    while (t--) {
//        cout << "Case " << (i ++)<<": \n";
//        printf("Case %d: \n", i++);

            solve();

        i++;
//        cout << "\n";
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

}

Measured memory_bytes: 3672