#include<bits/stdc++.h>
using namespace std ;
int main(){
    int t ;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        // pair.first --> value ; pair.second --> idx  
        vector<pair<long long,int>> v(n),copy(n);
        for(int i = 0 ; i < n ; i++){
            cin>>v[i].first;
            v[i].second = i+1 ;
        }
        sort(v.begin(),v.end());
        copy = v ;
        //copy -- > og vector 
        // v --> changed vector 
        for(int i = 1 ; i< n ; i++){
            v[i].first += (v[i-1].first - (v[i].first % v[i-1].first));
        }
        cout<<n<<"\n";
        for(int i = 0 ; i< n ; i++){
            cout<<v[i].second<<' '<<v[i].first-copy[i].first<<"\n";
        }
        // 3 6 348 6 12 

    }
}