/// Codeforces E - Round Dace
/// https://c...content-available-to-author-only...s.com/contest/1833/problem/E
/// Author: Qwerty
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 100;
int g[MAXN];
int vis[MAXN];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--){
int n;
cin >> n;
memset(vis, 0, sizeof(vis));
for (int i = 1; i <= n; i++){
cin >> g[i];
}
int b = 0;
int c = 0;
for (int i = 1; i <= n; i++){
if (!vis[i]){
int x = i;
int p = x;
int pp = p;
while (!vis[x]){
vis[x] = 1;
int v = g[x];
pp = p;
p = x;
x = v;
}
if (x == pp) b++;
else if (x == i) c++;
}
}
cout << c + min(b, 1) << " " << c + b << '\n';
}
}
Ly8vIENvZGVmb3JjZXMgRSAtIFJvdW5kIERhY2UKLy8vIGh0dHBzOi8vYy4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4ucy5jb20vY29udGVzdC8xODMzL3Byb2JsZW0vRQovLy8gQXV0aG9yOiBRd2VydHkKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY29uc3QgaW50IE1BWE4gPSAyZTUgKyAxMDA7CmludCBnW01BWE5dOwppbnQgdmlzW01BWE5dOwppbnQgbWFpbigpewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBpbnQgdDsKICAgIGNpbiA+PiB0OwogICAgd2hpbGUgKHQtLSl7CiAgICAgICAgIGludCBuOwogICAgICAgICBjaW4gPj4gbjsKICAgICAgICAgbWVtc2V0KHZpcywgMCwgc2l6ZW9mKHZpcykpOwogICAgICAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspewogICAgICAgICAgICAgIGNpbiA+PiBnW2ldOwogICAgICAgICB9CiAgICAgICAgIGludCBiID0gMDsKICAgICAgICAgaW50IGMgPSAwOwogICAgICAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspewogICAgICAgICAgICAgIGlmICghdmlzW2ldKXsKICAgICAgICAgICAgICAgICAgaW50IHggPSBpOwogICAgICAgICAgICAgICAgICBpbnQgcCA9IHg7CiAgICAgICAgICAgICAgICAgIGludCBwcCA9IHA7CiAgICAgICAgICAgICAgICAgIHdoaWxlICghdmlzW3hdKXsKICAgICAgICAgICAgICAgICAgICAgIHZpc1t4XSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICBpbnQgdiA9IGdbeF07CiAgICAgICAgICAgICAgICAgICAgICBwcCA9IHA7CiAgICAgICAgICAgICAgICAgICAgICBwID0geDsKICAgICAgICAgICAgICAgICAgICAgIHggPSB2OwogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgIGlmICh4ID09IHBwKSBiKys7CiAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKHggPT0gaSkgYysrOwogICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgICAgICBjb3V0IDw8IGMgKyBtaW4oYiwgMSkgPDwgIiAiIDw8IGMgKyBiIDw8ICdcbic7CiAgICB9Cn0K
MTAKNgoyIDEgNCAzIDYgNQo2CjIgMyAxIDUgNiA0CjkKMiAzIDIgNSA2IDUgOCA5IDgKMgoyIDEKNAo0IDMgMiAxCjUKMiAzIDQgNSAxCjYKNSAzIDQgMSAxIDIKNQozIDUgNCAxIDIKNgo2IDMgMiA1IDQgMwo2CjUgMSA0IDMgNCAyCg==
10
6
2 1 4 3 6 5
6
2 3 1 5 6 4
9
2 3 2 5 6 5 8 9 8
2
2 1
4
4 3 2 1
5
2 3 4 5 1
6
5 3 4 1 1 2
5
3 5 4 1 2
6
6 3 2 5 4 3
6
5 1 4 3 4 2