//Jackson Simoneau
//COP 3503H - Fall 2026
//P3: Counting Oranges

import java.util.*;
public class oranges {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int t = input.nextInt();

        //run a prime sieve to find all primes up to 10^7
        boolean[] isPrime = new boolean[10000001];
        for(int i = 2; i < 10000001; i++) isPrime[i] = true;
        
        for(int i = 2; i*i < 10000001; i++) {
            for(int j = 2; i*j < 10000001; j++) {
                isPrime[i*j] = false;
            }
        }

        //process test cases
        while(t-- > 0) {
            int n = input.nextInt();
            int q = input.nextInt();

            //track sum of values and how many values are prime
            BIT total_bit = new BIT(n);
            BIT prime_bit = new BIT(n);

            for(int i = 0; i < n; i++) {
                int v = input.nextInt();
                total_bit.update(i, v);
                if(isPrime[v]) prime_bit.update(i, 1);
            }

            //process queries
            while(q-- > 0) {
                int type = input.nextInt();
                if(type == 1) {
                    int i = input.nextInt();
                    int d = input.nextInt();
                    i--;

                    //find the current value at index i
                    long cv = total_bit.query(i+1) - total_bit.query(i);
                    long nv = cv + d;

                    total_bit.update(i, nv-cv);
                    if(isPrime[(int)cv] && !isPrime[(int)nv]) prime_bit.update(i, -1);
                    if(!isPrime[(int)cv] && isPrime[(int)nv]) prime_bit.update(i, 1);

                } else {
                    int l = input.nextInt();
                    int r = input.nextInt();
                    l--; r--;

                    //find sum of values and number of prime values in [l, r]
                    long sum = total_bit.query(r+1) - total_bit.query(l);
                    long prime = prime_bit.query(r+1) - prime_bit.query(l);

                    System.out.println(sum + " " + prime);
                }
            }
        }
    }
}

//binary index tree
class BIT {
    int n; long[] s;
    public BIT(int n) {
        this.n = n;
        s = new long[n];
    }

    //updates the value at pos by dif
    public void update(int pos, long dif) {
        for(; pos < n; pos |= pos+1) s[pos] += dif;
    }

    //queries the sum over [0, pos)
    long query(int pos) {
        long res = 0;
        for(; pos > 0; pos &= pos-1) res += s[pos-1];
        return res;
    }
}