#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void solve(int n, vector<int>&temp){
        if(n<=3){
                return;
        }
        else{
                for(int i=2; i<=n; ++i){
                        for(int j=i*i; j<=n; j += i){
                                if(temp[j]==0 && j%i==0){
                                        temp[j]=i;
                                }
                        }
                }
        }
}
int main(){
        int t;
        cin >> t;
        while(t--){
                int n;
                cin >> n;
                vector<int>temp(n+1,0);
                solve(n, temp);
                vector<int>dp(n+1,0);
                dp[2] = 1;
                dp[3] = 2;
                for(int i=4; i<=n; ++i){
                        if(temp[i]){
                                dp[i] = 1 + dp[temp[i]];
                        }
                        else{
                                dp[i] = 1+dp[i-1];
                        }
                }
        }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void solve(int n, vector<int>&temp){
        if(n<=3){
                return;
        }
        else{
                for(int i=2; i<=n; ++i){
                        for(int j=i*i; j<=n; j += i){
                                if(temp[j]==0 && j%i==0){
                                        temp[j]=i;
                                }
                        }
                }
        }
}
int main(){
        int t;
        cin >> t;
        while(t--){
                int n;
                cin >> n;
                if(n<=3){
                        cout << n-1 << endl;
                }
                else if(n&1==0 && n>2){
                        cout << 3 << endl;
                }
                else{
                vector<int>temp(n+1,0);
                solve(n, temp);
                vector<int>dp(n+1,3);
                dp[2] = 1;
                dp[3] = 2;
                for(int i=5; i<=n; i+=2){
                        if(temp[i]){
                                dp[i] = 1 + dp[temp[i]];
                        }
                        else{
                                dp[i] = 1+dp[i-1];
                        }
                }
                cout << dp[n] << endl;
                }
        }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void solve(int n, vector<int>&temp){
        if(n<=3){
                return;
        }
        else{
                for(int i=2; i<=n; ++i){
                        for(int j=i*i; j<=n; j += i){
                                if(temp[j]==0 && j%i==0){
                                        temp[j]=i;
                                }
                        }
                }
        }
}
int main(){
        int t;
        cin >> t;
        while(t--){
                int n;
                cin >> n;
                if(n<=3){
                        cout << n-1 << endl;
                }
                else if(n>2 && n&1==0){
                        cout << 2 << endl;
                }
                else{
                        vector<int>temp(n+1,0);
                        if(temp[n]==0){
                                cout << 3 << endl;
                        }
                        else{
                                cout << 3 << endl;
                        }
                }

        }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void solve(int n, vector<int>&temp){
        if(n<=3){
                return;
        }
        else{
                for(int i=2; i<=n; ++i){
                        for(int j=i*i; j<=n; j += i){
                                if(temp[j]==0 && j%i==0){
                                        temp[j]=i;
                                }
                        }
                }
        }
}
int main(){
        int t;
        cin >> t;
        while(t--){
                int n;
                cin >> n;
                vector<int>temp(n+1,0);
                solve(n, temp);
                vector<int>dp(n+1,0);
                dp[2] = 1;
                dp[3] = 2;
                for(int i=4; i<=n; ++i){
                        if(temp[i]){
                                dp[i] = 1 + dp[temp[i]];
                        }
                        else{
                                dp[i] = 1+dp[i-1];
                        }
                }
                cout << dp[n] << endl;
        }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void solve(int n, vector<int>&temp){
        if(n<=3){
                return;
        }
        else{
                for(int i=2; i<=n; ++i){
                        for(int j=i*i; j<=n; j += i){
                                if(temp[j]==0 && j%i==0){
                                        temp[j]=i;
                                }
                        }
                }
        }
}
int main(){
        int t;
        cin >> t;
        while(t--){
                int n;
                cin >> n;
                if(n<=3){
                        cout << n-1 << endl;
                }
                else if(n>2 && n%2==0){
                        cout << 2 << endl;
                }
                else{
                        cout << 3 << endl;
                }

        }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void solve(int n, vector<int>&temp){
        if(n<=3){
                return;
        }
        else{
                for(int i=2; i<=n; ++i){
                        for(int j=i*i; j<=n; j += i){
                                if(temp[j]==0 && j%i==0){
                                        temp[j]=i;
                                }
                        }
                }
        }
}
int main(){
        int t;
        cin >> t;
        while(t--){
                int n;
                cin >> n;
                if(n<=3){
                        cout << n-1 << endl;
                }
                else if(n>2 && n&1==0){
                        cout << 2 << endl;
                }
                else{
                        vector<int>temp(n+1,0);
                        if(temp[n]==0){
                                cout << 3 << endl;
                        }
                        else{
                                vector<int>dp(n+1,2);
                                dp[0]=0;
                                dp[1] =0;
                                dp[2] = 1;
                                for(int i=5; i<=n; i+=2){
                                        if(temp[i]==0){
                                                dp[i]=3;
                                        }
                                        else{
                                                dp[i] = 1+dp[temp[i]];
                                        }
                                }
                                cout << dp[n] << endl;
                        }
                }

        }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void solve(int n, vector<int>&temp){
        if(n<=3){
                return;
        }
        else{
                for(int i=2; i<=n; ++i){
                        for(int j=i*i; j<=n; j += i){
                                if(temp[j]==0 && j%i==0){
                                        temp[j]=i;
                                }
                        }
                }
        }
}
int main(){
        int t;
        cin >> t;
        while(t--){
                int n;
                cin >> n;
                if(n<=3){
                        cout << n-1 << endl;
                }
                else if(n>2 && n%2==0){
                        cout << 2 << endl;
                }
                else{
                        vector<int>temp(n+1,0);
                        if(temp[n]==0){
                                cout << 3 << endl;
                        }
                        else{
                                cout << 9 << endl;
                        }
                }

        }
}


#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
void solve(vector<ll>&temp, ll n){
        for(ll i=2; i<=n; ++i){
                for(ll j=i*i; j<=n; j += i){
                        if(temp[j]==0){
                                temp[j]=i;
                        }
                }
        }
}
int main(){
        int t;
        cin >> t;
        while(t--){
                ll n;
                cin >> n;
                vector<ll>dp(n+1);
                dp[1]=0;
                dp[2]=1;
                dp[3]=2;
                vector<ll>temp(n+1,0);
               solve(temp,n);
               for(ll i=4; i<=n; ++i){
                       if(temp[i]){
                               dp[i] = 1 + dp[temp[i]];
                       }
                       else{
                               dp[i] = 1 + dp[i-1];
                       }
               }
               cout << dp[n] << endl;
        }
}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
int main(){
    int t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        if(n<=3)
            cout<<n-1<<endl;
        else if(n & 1)
            cout<<"3"<<endl;
        else
            cout<<"2"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
using namespace std;
int ans;
const int Nmax=1000001;
bool prime[Nmax];
void sieve(){
	for(int i=3;i<=Nmax;i+=2){
		prime[i]=true;
	}
	prime[2]=true;
	for(int i=3;i<sqrt(Nmax);i+=2){
		if(prime[i]){
			for(int j=i*i;j<Nmax;j+=i)
				prime[i]=false;
		}
	}
}
bool is_prime(int n){
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0)
			return false;
	}
	return true;
}
int min_divisor(int n){
	for(int i=2;i<=sqrt(n);i++){
		if(prime)
			return i;
	}
}
int min_number_of_steps(int n){
	if(n==1)
		return ans;
	else if(is_prime(n)){
		ans++;
		return min_number_of_steps(n-1);
	}
	else{
		int div=min_divisor(n);
		ans++;
		return min_number_of_steps(div);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	sieve();
	int t;
	cin>>t;
	while(t--){
		ans=0;
		ll n;
		cin>>n;
		cout<<min_number_of_steps(n)<<endl;
	}
}


#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
using namespace std;
int ans;
const int Nmax=1000001;
bool prime[Nmax];
void sieve(){
	for(int i=3;i<=10000;i+=2){
		prime[i]=true;
	}
	prime[2]=true;
	for(int i=3;i<=sqrt(10000);i+=2){
		if(prime[i]){
			for(int j=i*i;j<Nmax;j+=i)
				prime[j]=false;
		}
	}
}
bool is_prime(int n){
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0)
			return false;
	}
	return true;
}
int min_divisor(int n){
	for(int i=2;i<=sqrt(n);i++){
		if(prime && n%i==0)
			return i;
	}
}
int min_number_of_steps(int n){
	if(n==1)
		return ans;
	else if(is_prime(n)){
		ans++;
		return min_number_of_steps(n-1);
	}
	else{
		int div=min_divisor(n);
		ans++;
		return min_number_of_steps(div);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	sieve();
	int t;
	cin>>t;
	while(t--){
		ans=0;
		ll n;
		cin>>n;
		cout<<min_number_of_steps(n)<<endl;
	}
}


#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
using namespace std;
int ans;
const int Nmax=1000001;
bool prime[Nmax];
void sieve(){
	for(int i=3;i<=1000000;i+=2){
		prime[i]=true;
	}
	prime[2]=true;
	for(ll i=3;i<=sqrt(1000000);i+=2){
		if(prime[i]){
			for(ll j=i*i;j<1000000;j+=i)
				prime[j]=false;
		}
	}
}
bool is_prime(ll n){
	for(ll i=2;i<=sqrt(n);i++){
		if(n%i==0)
			return false;
	}
	return true;
}
ll min_divisor(ll n){
	for(int i=2;i<=sqrt(n);i++){
		if(prime[i] && n%i==0)
			return i;
	}
}
ll min_number_of_steps(ll n){
	if(n==1)
		return ans;
	else if(prime[n]){
		ans++;
		return min_number_of_steps(n-1);
	}
	else{
		ll div=min_divisor(n);
		ans++;
		return min_number_of_steps(div);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	sieve();
	int t;
	cin>>t;
	while(t--){
		ans=0;
		ll n;
		cin>>n;
		cout<<min_number_of_steps(n)<<endl;
	}
}


#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
using namespace std;
int ans;
const int Nmax=1000001;
bool prime[Nmax];
void sieve(){
	for(int i=3;i<=1000000;i+=2){
		prime[i]=true;
	}
	prime[2]=true;
	for(ll i=3;i<=sqrt(1000000);i+=2){
		if(prime[i]){
			for(ll j=i*i;j<1000000;j+=i)
				prime[j]=false;
		}
	}
}
bool is_prime(ll n){
	for(ll i=2;i<=sqrt(n);i++){
		if(n%i==0)
			return false;
	}
	return true;
}
ll min_divisor(ll n){
	for(int i=2;i<=sqrt(n);i++){
		if(prime && n%i==0)
			return i;
	}
}
ll min_number_of_steps(ll n){
	if(n==1)
		return ans;
	else if(is_prime(n)){
		ans++;
		return min_number_of_steps(n-1);
	}
	else{
		ll div=min_divisor(n);
		ans++;
		return min_number_of_steps(div);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	sieve();
	int t;
	cin>>t;
	while(t--){
		ans=0;
		ll n;
		cin>>n;
		cout<<min_number_of_steps(n)<<endl;
	}
}


#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
using namespace std;
int ans;
const int Nmax=1000001;
bool prime[Nmax];
void sieve(){
	for(int i=3;i<=1000000;i+=2){
		prime[i]=true;
	}
	prime[2]=true;
	for(ll i=3;i<=sqrt(1000000);i+=2){
		if(prime[i]){
			for(ll j=i*i;j<1000000;j+=i)
				prime[j]=false;
		}
	}
}
bool is_prime(ll n){
	for(ll i=2;i<=sqrt(n);i++){
		if(n%i==0)
			return false;
	}
	return true;
}
ll min_divisor(ll n){
	for(int i=2;i<=sqrt(n);i++){
		if(prime[i] && n%i==0)
			return i;
	}
}
ll min_number_of_steps(ll n){
	if(n==1)
		return ans;
	else if(prime[n]){
		ans++;
		return min_number_of_steps(n-1);
	}
	else{
		ll div=min_divisor(n);
		ans++;
		return min_number_of_steps(div);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	sieve();
	int t;
	cin>>t;
	while(t--){
		ans=0;
		ll n;
		cin>>n;
		if(n<1){
			cout<<"0";
			continue;
		}
		cout<<min_number_of_steps(n)<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
template<class T> using pii = pair<T, T>;
template<class T> using vi = vector<T>;

const int MOD = 1000000007;
const int N = 1001;

bool isPrime(int n) {
    for(int i = 2; 1LL * i * i <= n; ++i)
        if(n % i == 0)
            return false;
    return n > 1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while(T--) {
        int n;
        cin >> n;
        if(isPrime(n)) {
            cout << n - 1 << "\n";
            continue;
        }
        int mx = n;
        for(int i = n - 1; i >= 1; i--) {
            if(n % i == 0) {
                mx = i;
                break;
            }
        }
        n /= mx;
        cout << n << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
template<class T> using pii = pair<T, T>;
template<class T> using vi = vector<T>;

const int MOD = 1000000007;
const int N = 1001;

bool isPrime(int n) {
    for(int i = 2; 1LL * i * i <= n; ++i)
        if(n % i == 0)
            return false;
    return n > 1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while(T--) {
        int n;
        cin >> n;
        int answer = 0;
        while(!isPrime(n) && n > 1) {
            int mx = -1;
            for(int i = n - 1; i >= 1; i--) {
                if(n % i == 0) {
                    mx = i;
                    break;
                }
            }
            answer += 1;
            n /= mx;
        }
        answer += (n - 1);
        cout << answer << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
template<class T> using pii = pair<T, T>;
template<class T> using vi = vector<T>;

const int MOD = 1000000007;
const int N = 1001;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while(T--) {
        int n;
        cin >> n;
        if(n == 1) {
            cout << 0 << "\n";
            continue;
        }
        bool ok = false;
        for(int i = 2; i < n; i++) {
            if(n % i == 0) {
                ok = true;
                cout << (i - 1) + (n != i) << "\n";
                break;
            }
        }
        if(!ok) cout << n - 1 << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
template<class T> using pii = pair<T, T>;
template<class T> using vi = vector<T>;

const int MOD = 1000000007;
const int N = 1001;

bool isPrime(int n) {
    for(int i = 2; 1LL * i * i <= n; ++i)
        if(n % i == 0)
            return false;
    return n > 1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while(T--) {
        int n;
        cin >> n;
        if(n == 1) {
            cout << 0 << "\n";
            continue;
        }
        if(isPrime(n)) {
            cout << n - 1 << "\n";
            continue;
        }
        int mx = n;
        for(int i = n - 1; i >= 1; i--) {
            if(n % i == 0) {
                mx = i;
                break;
            }
        }
        n /= mx;
        cout << n << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
template<class T> using pii = pair<T, T>;
template<class T> using vi = vector<T>;

const int MOD = 1000000007;
const int N = 1001;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while(T--) {
        int n;
        cin >> n;
        if(n == 1) {
            cout << 0 << "\n";
            continue;
        }
        for(int i = 2; ; i++) {
            if(n % i == 0) {
                cout << (i - 1) + (n != i) << "\n";
                break;
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
template<class T> using pii = pair<T, T>;
template<class T> using vi = vector<T>;

const int MOD = 1000000007;
const int N = 1001;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin.exceptions(cin.failbit);
    int T;
    cin >> T;
    while(T--) {
        int n;
        cin >> n;
        if(n == 1) {
            cout << 0 << "\n";
            continue;
        }
        bool ok = false;
        for(int i = 2; i < n; i++) {
            if(n % i == 0) {
                ok = true;
                cout << (i - 1) + (n != i) << "\n";
                break;
            }
        }
        if(!ok) {
            int answer = 0;
            while(n & 1) n--, answer++;
            cout << answer + 2 << "\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
template<class T> using pii = pair<T, T>;
template<class T> using vi = vector<T>;

const int MOD = 1000000007;
const int N = 1001;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin.exceptions(cin.failbit);
    int T;
    cin >> T;
    while(T--) {
        int n;
        cin >> n;
        if(n == 1) {
            cout << 0 << "\n";
            continue;
        }
        int answer = 0;
        while(n & 1) {
            answer++;
            n--;
        }
        answer += (n != 2);
        cout << answer + 1 << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
#define ans(z) cout << "Case #" << z << ": "
auto t1 = chrono::high_resolution_clock::now();
vector<ll> divisor(ll number)
{
    ll i;
    vector<ll> v;
    for (i = 2; i <= sqrt(number); i++)
    {
        if (number % i == 0 and number != i)
            v.pb(i);
    }
    return v;
}
ll steps(ll n, ll *x)
{
    //cout << n << endl;
    if (n == 1)
        return 0;
    vector<ll> v = divisor(n);
    ll step = 0;
    if (!v.size())
        *x = steps(n - 1, x);
    else
    {
        for (ll it : v)
            step += steps(n / it, x), *x = min(*x, step), step = 0;
    }
    *x += 1;
    return *x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll x = INT_MAX;
        vector<ll> v = divisor(n);
        // for (ll it : v)
        //     cout << it << " ";
        show(steps(n, &x));
    }
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
#define ans(z) cout << "Case #" << z << ": "
auto t1 = chrono::high_resolution_clock::now();
vector<ll> divisor(ll number)
{
    ll i;
    vector<ll> v;
    for (i = 2; i <= sqrt(number) + 1; i++)
    {
        if (number % i == 0 and number != i)
            v.pb(i);
    }
    return v;
}
ll steps(ll n, ll *x)
{
    //cout << n << endl;
    if (n == 1)
        return 0;
    vector<ll> v = divisor(n);
    ll step = 0;
    if (!v.size())
        *x = steps(n - 1, x);
    else
    {
        for (ll it : v)
            step += steps(n / it, x), *x = min(*x, step), step = 0;
    }
    *x += 1;
    return *x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll x = INT_MAX;
        vector<ll> v = divisor(n);
        // for (ll it : v)
        //     cout << it << " ";
        show(steps(n, &x));
    }
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
#define ans(z) cout << "Case #" << z << ": "
auto t1 = chrono::high_resolution_clock::now();
ll divisor(ll number)
{
    ll i;
    for (i = 2; i <= (ll)sqrt(number); i++)
    {
        if (number % i == 0)
            return (number / i);
    }
    return 1;
}
// ll steps(ll n, ll *x)
// {
//     //cout << n << endl;
//     if (n == 1)
//         return 0;
//     ll step = 0;
//     if (!v.size())
//         *x = steps(n - 1, x);
//     else
//     {
//         for (ll it : v)
//             step += steps(n / it, x), *x = min(*x, step), step = 0;
//     }
//     *x += 1;
//     return *x;
// }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll count = 0;
        while (n != 1)
        {
            ll x = divisor(n);
            if (x == 1)
                n--;
            else
                n /= x;
            count++;
        }
        show(count);
    }
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
#define ans(z) cout << "Case #" << z << ": "
auto t1 = chrono::high_resolution_clock::now();
ll divisor(ll number)
{
    ll i;
    for (i = 2; i <= (ll)sqrt(number); i++)
    {
        if (number % i == 0)
            return (number / i);
    }
    return 1;
}
// ll steps(ll n, ll *x)
// {
//     //cout << n << endl;
//     if (n == 1)
//         return 0;
//     ll step = 0;
//     if (!v.size())
//         *x = steps(n - 1, x);
//     else
//     {
//         for (ll it : v)
//             step += steps(n / it, x), *x = min(*x, step), step = 0;
//     }
//     *x += 1;
//     return *x;
// }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        if (n == 1 or n == 2)
            show(n);
        else if (n == 3)
            show("2");
        else if (n % 2 == 0)
            show("2");
        else
            show("3");
    }
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
#define ans(z) cout << "Case #" << z << ": "
auto t1 = chrono::high_resolution_clock::now();
ll divisor(ll number)
{
    ll i;
    for (i = 2; i <= sqrt(number); i++)
    {
        if (number % i == 0)
        {
            return number / i;
        }
    }
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll count = 0;
        while (n != 1)
        {
            ll x = divisor(n);
            if (n == x or x == 1)
                n--;
            count++;
            n /= x;
        }
        show(count);
    }
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
#define ans(z) cout << "Case #" << z << ": "
auto t1 = chrono::high_resolution_clock::now();
ll divisor(ll number)
{
    ll i;
    for (i = 2; i <= (ll)sqrt(number); i++)
    {
        if (number % i == 0)
            return (number / i);
    }
    return 1;
}
// ll steps(ll n, ll *x)
// {
//     //cout << n << endl;
//     if (n == 1)
//         return 0;
//     ll step = 0;
//     if (!v.size())
//         *x = steps(n - 1, x);
//     else
//     {
//         for (ll it : v)
//             step += steps(n / it, x), *x = min(*x, step), step = 0;
//     }
//     *x += 1;
//     return *x;
// }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        if (n == 1 or n == 2 or n == 3)
            show(n - 1);

        else if (n % 2 == 0)
            show("2");
        else
            show("3");
    }
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
#define ans(z) cout << "Case #" << z << ": "
auto t1 = chrono::high_resolution_clock::now();
ll divisor(ll number)
{
    ll i;
    for (i = 2; i <= sqrt(number); i++)
    {
        if (number % i == 0)
        {
            return number / i;
        }
    }
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll count = 0;
        while (n != 1)
        {
            ll x = divisor(n);
            if (n == x or x == 1)
                n--;
            else
                n /= x;
            count++;
        }
        show(count);
    }
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
#define ans(z) cout << "Case #" << z << ": "
auto t1 = chrono::high_resolution_clock::now();
ll divisor(ll number)
{
    ll i;
    for (i = 2; i <= sqrt(number); i++)
    {
        if (number % i == 0)
            return (number / i);
    }
    return 1;
}
// ll steps(ll n, ll *x)
// {
//     //cout << n << endl;
//     if (n == 1)
//         return 0;
//     ll step = 0;
//     if (!v.size())
//         *x = steps(n - 1, x);
//     else
//     {
//         for (ll it : v)
//             step += steps(n / it, x), *x = min(*x, step), step = 0;
//     }
//     *x += 1;
//     return *x;
// }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll count = 0;
        while (n != 1)
        {
            ll x = divisor(n);
            if (x == 1)
                n--;
            else
                n /= x;
            count++;
        }
        show(count);
    }
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define go(i, a, n) for (ll i = a; i < (ll)n; i++)
#define gor(i, a, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define show(a) cout << a << '\n'
#define show2(a, b) cout << a << " " << b << '\n'
#define show3(a, b, c) cout << a << " " << b << " " << c << '\n'
#define show4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n'
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
#define ans(z) cout << "Case #" << z << ": "
auto t1 = chrono::high_resolution_clock::now();
ll divisor(ll number)
{
    ll i;
    for (i = 2; i <= sqrt(number); i++)
    {
        if (number % i == 0)
        {
            return number / i;
        }
    }
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll count = 0;
        while (n != 1)
        {
            ll x = divisor(n);
            if (n == x or x == 1)
            {
                count += n - 1;
                break;
            }
            count++;
            n /= x;
        }
        show(count);
    }
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#define maxn 222222
using namespace std;

long long a[maxn];
long long li[maxn],ri[maxn],c[maxn],d[maxn];

struct tree{
    long long l,r;
    long long sum,add;
}s[maxn*4];

void pushdown(long long o,long long m)
{
    if(s[o].add){
        s[o*2].add+=s[o].add;
        s[o*2+1].add+=s[o].add;
        s[o*2].sum+=s[o].add*(m-(m/2));
        s[o*2+1].sum+=s[o].add*(m/2);
        s[o].add=0;
    }
}

void build(long long o,long long l,long long r)
{
    s[o].l=l;
    s[o].r=r;
    s[o].add=0;
    if(l==r) {
        s[o].sum=a[l];
        return;
    }
    long long m=(l+r)/2;
    build(o*2,l,m);
    build(o*2+1,m+1,r);
    s[o].sum=s[o*2].sum+s[o*2+1].sum;
}

void update(long long o,long long l,long long r,long long v)
{
    if(l<=s[o].l&&s[o].r<=r){
        s[o].add+=v;
        s[o].sum+=(long long)v*(s[o].r-s[o].l+1);
        return;
    }
    pushdown(o,s[o].r-s[o].l+1);
    long long m=(s[o].l+s[o].r)/2;
    if(l<=m) update(o*2,l,r,v);
    if(m<r)update(o*2+1,l,r,v);

}

long long query(long long o,long long l,long long r)
{

    if(l<=s[o].l&&r>=s[o].r)
        return s[o].sum;
    pushdown(o,s[o].r-s[o].l+1);
    long long m=(s[o].l+s[o].r)/2;
    long long ret=0;
    if(l<=m) ret+=query(o*2,l,r);
    if(m<r) ret+=query(o*2+1,l,r);
    return ret;
}

int main()
{
    long long n,m,k;
    //freopen("E:\\in.txt","r",stdin);
    while(scanf("%I64d%I64d%I64d",&n,&m,&k)!=EOF)
    {
        memset(c,0,sizeof(c));
        for(long long i=1;i<=n;i++)
            scanf("%I64d",&a[i]);
        build(1,1,n);
        for(long long i=1;i<=m;i++)
        {
            scanf("%I64d %I64d %I64d",&li[i],&ri[i],&d[i]);
        }
        while(k--)
        {
            long long x,y;
            scanf("%I64d%I64d",&x,&y);
            c[x] += 1;
            c[y+1] -= 1;
        }
        for(long long i=2;i<=m;i++)c[i]+=c[i-1];
        for(long long i=1;i<=m;i++)update(1,li[i],ri[i],d[i]*c[i]);
        printf("%I64d",query(1,1,1));
        for(long long i=2;i<=n;i++)
        {
            printf(" %I64d",query(1,i,i));
        }
        printf("\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
typedef long long ll;
#define lson num << 1
#define rson num << 1 | 1
struct node
{
    int l,r;
    ll sum;
    ll lazy;
}tree[MAXN << 2];
int cnt[MAXN];
ll a[MAXN];
int opl[MAXN],opr[MAXN];
ll val[MAXN];
void pushup(int num)
{
    tree[num].sum = tree[lson].sum + tree[rson].sum;
}
void pushdown(int num)
{
    if(tree[num].lazy) {
        //printf("%d %d %d %d&&&&&&&\n",num,tree[num].l,tree[num].r,tree[num].lazy);
        int mid = (tree[num].l + tree[num].r) / 2;
        int len1 = mid - tree[num].l + 1;
        int len2 = tree[num].r - mid;
        tree[lson].lazy += tree[num].lazy;
        tree[rson].lazy += tree[num].lazy;
        tree[lson].sum += (tree[num].lazy * len1);
        tree[rson].sum += (tree[num].lazy * len2);
        tree[num].lazy = 0;
    }
}
void build(int num,int l,int r)
{
    tree[num].l = l;
    tree[num].r = r;
    tree[num].sum = 0;
    tree[num].lazy = 0;
    if(l == r) {
        return;
    }
    int mid = (l + r) >> 1;
    build(lson,l,mid);
    build(rson,mid + 1,r);
    pushup(num);
}
void update(int num,int l,int r,ll val)
{
    if(tree[num].l == l && tree[num].r == r) {
        tree[num].sum += (r - l + 1) * val;
        tree[num].lazy += val;
        return;
    }
    pushdown(num);
    int mid = (tree[num].l + tree[num].r) >> 1;
    if(r <= mid) update(lson,l,r,val);
    else if(l > mid) update(rson,l,r,val);
    else {
        update(lson,l,mid,val);
        update(rson,mid + 1,r,val);
    }
    pushup(num);
}
ll query(int num,int l,int r)
{
    pushdown(num);
    if(tree[num].l == l && tree[num].r == r) {
        return tree[num].sum;
    }
    ll sum = 0;
    int mid = (tree[num].l + tree[num].r) >> 1;
    if(r <= mid) sum += query(lson,l,r);
    else if(l > mid) sum += query(rson,l,r);
    else {
        sum += ( query(lson,l,mid) + query(rson,mid + 1,r) );
    }
    pushup(num);
    return sum;
}
int main(void)
{
    int n,m,k;
    int l,r;
    scanf("%d %d %d",&n,&m,&k);
    for(int i = 1; i <= n; i++) scanf("%I64d",&a[i]);
    for(int i = 1; i <= m; i++) scanf("%d %d %I64d",&opl[i],&opr[i],&val[i]);
    build(1,1,m);
    for(int i = 1; i <= k; i++) {
        scanf("%d %d",&l,&r);
        update(1,l,r,1);
    }
    for(int i = 1; i <= m; i++) {
        cnt[i] = query(1,i,i);
        val[i] *= cnt[i];
    }
    build(1,1,n);
    for(int i = 1; i <= m; i++) {
        update(1,opl[i],opr[i],val[i]);
    }
    for(int i = 1; i <= n; i++) {
        if(i == 1) printf("%I64d",a[i] + query(1,i,i));
        else printf(" %I64d",a[i] + query(1,i,i));
    }
    printf("\n");
    return 0;
}
/*
3 3 3
1 2 3
1 2 1
1 3 2
2 3 4
1 2
1 3
2 3
*/


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
typedef long long ll;
#define lson num << 1
#define rson num << 1 | 1
struct node
{
    ll l,r;
    ll sum;
    ll lazy;
}tree[MAXN << 2];
ll cnt[MAXN];
ll a[MAXN];
ll opl[MAXN],opr[MAXN];
ll val[MAXN];
void pushup(ll num)
{
    tree[num].sum = tree[lson].sum + tree[rson].sum;
}
void pushdown(ll num)
{
    if(tree[num].lazy) {
        //printf("%d %d %d %d&&&&&&&\n",num,tree[num].l,tree[num].r,tree[num].lazy);
        ll mid = (tree[num].l + tree[num].r) >> 1;
        ll len1 = mid - tree[num].l + 1;
        ll len2 = tree[num].r - mid;
        tree[lson].lazy += tree[num].lazy;
        tree[rson].lazy += tree[num].lazy;
        tree[lson].sum += (tree[num].lazy * len1);
        tree[rson].sum += (tree[num].lazy * len2);
        tree[num].lazy = 0;
    }
}
void build(ll num,ll l,ll r)
{
    tree[num].l = l;
    tree[num].r = r;
    tree[num].sum = 0;
    tree[num].lazy = 0;
    if(l == r) {
        return;
    }
    ll mid = (l + r) >> 1;
    build(lson,l,mid);
    build(rson,mid + 1,r);
    pushup(num);
}
void update(ll num,ll l,ll r,ll val)
{
    if(tree[num].l == l && tree[num].r == r) {
        tree[num].sum += (r - l + 1) * val;
        tree[num].lazy += val;
        return;
    }
    pushdown(num);
    ll mid = (tree[num].l + tree[num].r) >> 1;
    if(r <= mid) update(lson,l,r,val);
    else if(l > mid) update(rson,l,r,val);
    else {
        update(lson,l,mid,val);
        update(rson,mid + 1,r,val);
    }
    pushup(num);
}
ll query(ll num,ll l,ll r)
{
    pushdown(num);
    if(tree[num].l == l && tree[num].r == r) {
        return tree[num].sum;
    }
    ll sum = 0;
    ll mid = (tree[num].l + tree[num].r) >> 1;
    if(r <= mid) sum += query(lson,l,r);
    else if(l > mid) sum += query(rson,l,r);
    else {
        sum += ( query(lson,l,mid) + query(rson,mid + 1,r) );
    }
    pushup(num);
    return sum;
}
int main(void)
{
    ll n,m,k;
    ll l,r;
    ll i;
    scanf("%I64d %I64d %I64d",&n,&m,&k);
    for(i = 1; i <= n; i++) scanf("%I64d",&a[i]);
    for(i = 1; i <= m; i++) scanf("%I64d %I64d %I64d",&opl[i],&opr[i],&val[i]);
    build(1ll,1ll,m);
    for(i = 1; i <= k; i++) {
        scanf("%I64d %I64d",&l,&r);
        update(1ll,l,r,1ll);
    }
    for(i = 1; i <= m; i++) {
        cnt[i] = query(1ll,i,i);
        val[i] *= cnt[i];
    }
    build(1ll,1ll,n);
    for(i = 1; i <= m; i++) {
        update(1,opl[i],opr[i],val[i]);
    }
    for(i = 1; i <= n; i++) {
        if(i == 1) printf("%I64d",a[i] + query(1ll,i,i));
        else printf(" %I64d",a[i] + query(1ll,i,i));
    }
    printf("\n");
    return 0;
}
/*
3 3 3
1 2 3
1 2 1
1 3 2
2 3 4
1 2
1 3
2 3
*/


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
typedef long long ll;
#define lson num << 1
#define rson num << 1 | 1
struct node
{
    ll l,r;
    ll sum;
    ll lazy;
}tree[MAXN << 2];
ll cnt[MAXN];
ll a[MAXN];
ll opl[MAXN],opr[MAXN];
ll val[MAXN];
void pushup(ll num)
{
    tree[num].sum = tree[lson].sum + tree[rson].sum;
}
void pushdown(ll num)
{
    if(tree[num].lazy) {
        //printf("%d %d %d %d&&&&&&&\n",num,tree[num].l,tree[num].r,tree[num].lazy);
        int mid = (tree[num].l + tree[num].r) / 2;
        ll len1 = mid - tree[num].l + 1;
        ll len2 = tree[num].r - mid;
        tree[lson].lazy += tree[num].lazy;
        tree[rson].lazy += tree[num].lazy;
        tree[lson].sum += (tree[num].lazy * len1);
        tree[rson].sum += (tree[num].lazy * len2);
        tree[num].lazy = 0;
    }
}
void build(ll num,ll l,ll r)
{
    tree[num].l = l;
    tree[num].r = r;
    tree[num].sum = 0;
    tree[num].lazy = 0;
    if(l == r) {
        return;
    }
    int mid = (l + r) >> 1;
    build(lson,l,mid);
    build(rson,mid + 1,r);
    pushup(num);
}
void update(ll num,ll l,ll r,ll val)
{
    if(tree[num].l == l && tree[num].r == r) {
        tree[num].sum += (ll)(r - l + 1) * val;
        tree[num].lazy += val;
        return;
    }
    pushdown(num);
    int mid = (tree[num].l + tree[num].r) >> 1;
    if(r <= mid) update(lson,l,r,val);
    else if(l > mid) update(rson,l,r,val);
    else {
        update(lson,l,mid,val);
        update(rson,mid + 1,r,val);
    }
    pushup(num);
}
ll query(ll num,ll l,ll r)
{
    pushdown(num);
    if(tree[num].l == l && tree[num].r == r) {
        return tree[num].sum;
    }
    ll sum = 0;
    int mid = (tree[num].l + tree[num].r) >> 1;
    if(r <= mid) sum += query(lson,l,r);
    else if(l > mid) sum += query(rson,l,r);
    else {
        sum += ( query(lson,l,mid) + query(rson,mid + 1,r) );
    }
    pushup(num);
    return sum;
}
int main(void)
{
    ll n,m,k;
    ll l,r;
    ll i;
    scanf("%I64d %I64d %I64d",&n,&m,&k);
    for(i = 1; i <= n; i++) scanf("%I64d",&a[i]);
    for(i = 1; i <= m; i++) scanf("%I64d %I64d %I64d",&opl[i],&opr[i],&val[i]);
    build(1,1,m);
    for(i = 1; i <= k; i++) {
        scanf("%I64d %I64d",&l,&r);
        update(1,l,r,(ll)1);
    }
    for(i = 1; i <= m; i++) {
        cnt[i] = query(1,i,i);
        val[i] *= cnt[i];
    }
    build(1,1,n);
    for(i = 1; i <= m; i++) {
        update(1,opl[i],opr[i],val[i]);
    }
    for(i = 1; i <= n; i++) {
        if(i == 1) printf("%I64d",a[i] + query(1,i,i));
        else printf(" %I64d",a[i] + query(1,i,i));
    }
    printf("\n");
    return 0;
}
/*
3 3 3
1 2 3
1 2 1
1 3 2
2 3 4
1 2
1 3
2 3
*/


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
typedef long long ll;
#define lson num << 1
#define rson num << 1 | 1
struct node
{
    ll l,r;
    ll sum;
    ll lazy;
}tree[MAXN << 2];
ll cnt[MAXN];
ll a[MAXN];
ll opl[MAXN],opr[MAXN];
ll val[MAXN];
void pushup(ll num)
{
    tree[num].sum = tree[lson].sum + tree[rson].sum;
}
void pushdown(ll num)
{
    if(tree[num].lazy) {
        tree[lson].lazy += tree[num].lazy;
        tree[rson].lazy += tree[num].lazy;
        tree[lson].sum += (tree[num].lazy * (tree[lson].r - tree[lson].l + 1));
        tree[rson].sum += (tree[num].lazy * (tree[rson].r - tree[rson].l + 1));
        tree[num].lazy = 0;
    }
}
void build(ll num,ll l,ll r)
{
    tree[num].l = l;
    tree[num].r = r;
    tree[num].sum = 0;
    tree[num].lazy = 0;
    if(l == r) {
        return;
    }
    ll mid = (l + r) >> 1;
    build(lson,l,mid);
    build(rson,mid + 1,r);
    pushup(num);
}
void update(ll num,ll l,ll r,ll val)
{
    if(tree[num].l == l && tree[num].r == r) {
        tree[num].sum += (r - l + 1) * val;
        tree[num].lazy += val;
        return;
    }
    pushdown(num);
    ll mid = (tree[num].l + tree[num].r) >> 1;
    if(r <= mid) update(lson,l,r,val);
    else if(l > mid) update(rson,l,r,val);
    else {
        update(lson,l,mid,val);
        update(rson,mid + 1,r,val);
    }
    pushup(num);
}
ll query(ll num,ll l,ll r)
{
    if(tree[num].l == l && tree[num].r == r) {
        return tree[num].sum;
    }
    pushdown(num);
    ll sum = 0;
    ll mid = (tree[num].l + tree[num].r) >> 1;
    if(r <= mid) sum += query(lson,l,r);
    else if(l > mid) sum += query(rson,l,r);
    else {
        sum += ( query(lson,l,mid) + query(rson,mid + 1,r) );
    }
    pushup(num);
    return sum;
}
int main(void)
{
    ll n,m,k;
    ll l,r;
    ll i;
    scanf("%I64d %I64d %I64d",&n,&m,&k);
    for(i = 1; i <= n; i++) scanf("%I64d",&a[i]);
    for(i = 1; i <= m; i++) scanf("%I64d %I64d %I64d",&opl[i],&opr[i],&val[i]);
    build(1ll,1ll,m);
    for(i = 1; i <= k; i++) {
        scanf("%I64d %I64d",&l,&r);
        update(1ll,l,r,1ll);
    }
    for(i = 1; i <= m; i++) {
        cnt[i] = query(1ll,i,i);
        val[i] *= cnt[i];
    }
    build(1ll,1ll,n);
    for(i = 1; i <= m; i++) {
        update(1,opl[i],opr[i],val[i]);
    }
    for(i = 1; i <= n; i++) {
        if(i == 1) printf("%I64d",a[i] + query(1ll,i,i));
        else printf(" %I64d",a[i] + query(1ll,i,i));
    }
    printf("\n");
    return 0;
}
/*
3 3 3
1 2 3
1 2 1
1 3 2
2 3 4
1 2
1 3
2 3
*/


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
typedef long long ll;
#define lson num << 1
#define rson num << 1 | 1
struct node
{
    int l,r;
    ll sum;
    ll lazy;
}tree[MAXN << 2];
int cnt[MAXN];
ll a[MAXN];
int opl[MAXN],opr[MAXN];
ll val[MAXN];
void pushup(int num)
{
    tree[num].sum = tree[lson].sum + tree[rson].sum;
}
void pushdown(int num)
{
    if(tree[num].lazy) {
        //printf("%d %d %d %d&&&&&&&\n",num,tree[num].l,tree[num].r,tree[num].lazy);
        int mid = (tree[num].l + tree[num].r) / 2;
        int len1 = mid - tree[num].l + 1;
        int len2 = tree[num].r - mid;
        tree[lson].lazy += tree[num].lazy;
        tree[rson].lazy += tree[num].lazy;
        tree[lson].sum += (tree[num].lazy * len1);
        tree[rson].sum += (tree[num].lazy * len2);
        tree[num].lazy = 0;
    }
}
void build(int num,int l,int r)
{
    tree[num].l = l;
    tree[num].r = r;
    tree[num].sum = 0;
    tree[num].lazy = 0;
    if(l == r) {
        return;
    }
    int mid = (l + r) >> 1;
    build(lson,l,mid);
    build(rson,mid + 1,r);
    pushup(num);
}
void update(int num,int l,int r,ll val)
{
    if(tree[num].l == l && tree[num].r == r) {
        tree[num].sum += (ll)(r - l + 1) * val;
        tree[num].lazy += val;
        return;
    }
    pushdown(num);
    int mid = (tree[num].l + tree[num].r) >> 1;
    if(r <= mid) update(lson,l,r,val);
    else if(l > mid) update(rson,l,r,val);
    else {
        update(lson,l,mid,val);
        update(rson,mid + 1,r,val);
    }
    pushup(num);
}
ll query(int num,int l,int r)
{
    pushdown(num);
    if(tree[num].l == l && tree[num].r == r) {
        return tree[num].sum;
    }
    ll sum = 0;
    int mid = (tree[num].l + tree[num].r) >> 1;
    if(r <= mid) sum += query(lson,l,r);
    else if(l > mid) sum += query(rson,l,r);
    else {
        sum += ( query(lson,l,mid) + query(rson,mid + 1,r) );
    }
    pushup(num);
    return sum;
}
int main(void)
{
    int n,m,k;
    int l,r;
    scanf("%d %d %d",&n,&m,&k);
    for(int i = 1; i <= n; i++) scanf("%I64d",&a[i]);
    for(int i = 1; i <= m; i++) scanf("%d %d %I64d",&opl[i],&opr[i],&val[i]);
    build(1,1,m);
    for(int i = 1; i <= k; i++) {
        scanf("%d %d",&l,&r);
        update(1,l,r,1);
    }
    for(int i = 1; i <= m; i++) {
        cnt[i] = query(1,i,i);
        val[i] *= cnt[i];
    }
    build(1,1,n);
    for(int i = 1; i <= m; i++) {
        update(1,opl[i],opr[i],val[i]);
    }
    for(int i = 1; i <= n; i++) {
        if(i == 1) printf("%I64d",a[i] + query(1,i,i));
        else printf(" %I64d",a[i] + query(1,i,i));
    }
    printf("\n");
    return 0;
}
/*
3 3 3
1 2 3
1 2 1
1 3 2
2 3 4
1 2
1 3
2 3
*/


#include <cstdio>
#define N 100005
typedef long long LL;
int n, m, k;
struct Node
{
	int a, b;
	LL sum, inc;
	Node() {}
	Node(int _a, int _b): a(_a), b(_b), sum(0), inc(0) {}
	int middle() { return (a+b)>>1; }
} an[N*4], qn[N*4];
void build(int l, int r, int d, Node t[])
{
	if (l > r) return ;
	t[d] = Node(l,r);
	if (l == r) return ;
	int mid = t[d].middle();
	build(l,mid,d<<1,t);
	build(mid+1,r,(d<<1)+1,t);
}
void update(int fo, int to, int v, int d, Node t[])
{
	t[d].sum += (to-fo+1)*v;
	if (fo==t[d].a && t[d].b==to)
	{
		t[d].inc += v;
		return ;
	}
	int mid = t[d].middle();
	if (mid>=fo && mid<to)
	{
		update(fo,mid,v,d<<1,t);
		update(mid+1,to,v,(d<<1)+1,t);
	}
	else if (mid < fo)
	{
		update(fo,to,v,(d<<1)+1,t);
	}
	else if (mid >= to)
	{
		update(fo,to,v,d<<1,t);
	}
}
LL quary(int fo, int to, int d, Node t[])
{
	if (fo==t[d].a && to==t[d].b) return t[d].sum;
	int mid = t[d].middle();
	if (mid>=fo && mid<to) return quary(fo,mid,d<<1,t) + quary(mid+1,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid < fo) return quary(fo,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid >= to) return quary(fo,to,d<<1,t) + (to-fo+1)*t[d].inc;
}
LL q[N][3], a[N];
int main()
{
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	while (scanf("%d%d%d",&n,&m,&k) != EOF)
	{
		build(1,n,1,an);
		build(1,m,1,qn);
		for (int i = 1; i <= n; ++ i)
			scanf("%d",&a[i]);
		for (int i = 1; i <= m; ++ i)
			for (int j = 0; j < 3; ++ j)
				scanf("%d",&q[i][j]);
		for (int i=0,l,r; i < k; ++ i)
		{
			scanf("%d%d",&l,&r);
			update(l,r,1,1,qn);
		}
		for (int i = 1; i <= m; ++ i)
			update(q[i][0],q[i][1],q[i][2]*quary(i,i,1,qn),1,an);
		for (int i = 1; i < n; ++ i)
			printf("%I64d ", a[i]+quary(i,i,1,an));
		printf("%I64d\n", a[n]+quary(n,n,1,an));
	}
}


#include <cstdio>
#define N 100005
typedef long long LL;
int n, m, k;
struct Node
{
	int a, b;
	LL sum, inc;
	Node() {}
	Node(int _a, int _b): a(_a), b(_b), sum(0), inc(0) {}
	int middle() { return (a+b)>>1; }
} an[N*4], qn[N*4];
void build(int l, int r, int d, Node t[])
{
	if (l > r) return ;
	t[d] = Node(l,r);
	if (l == r) return ;
	int mid = t[d].middle();
	build(l,mid,d<<1,t);
	build(mid+1,r,(d<<1)+1,t);
}
void update(int fo, int to, int v, int d, Node t[])
{
	t[d].sum += (to-fo+1)*v;
	if (fo==t[d].a && t[d].b==to)
	{
		t[d].inc += v;
		return ;
	}
	int mid = t[d].middle();
	if (mid>=fo && mid<to)
	{
		update(fo,mid,v,d<<1,t);
		update(mid+1,to,v,(d<<1)+1,t);
	}
	else if (mid < fo)
	{
		update(fo,to,v,(d<<1)+1,t);
	}
	else if (mid >= to)
	{
		update(fo,to,v,d<<1,t);
	}
}
LL quary(int fo, int to, int d, Node t[])
{
	if (fo==t[d].a && to==t[d].b) return t[d].sum;
	int mid = t[d].middle();
	if (mid>=fo && mid<to) return quary(fo,mid,d<<1,t) + quary(mid+1,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid < fo) return quary(fo,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid >= to) return quary(fo,to,d<<1,t) + (to-fo+1)*t[d].inc;
}
LL q[N][3], a[N];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	while (scanf("%d%d%d",&n,&m,&k) != EOF)
	{
		build(1,n,1,an);
		build(1,n,1,qn);
		for (int i = 1; i <= n; ++ i)
			scanf("%d",&a[i]);
		for (int i = 1; i <= m; ++ i)
			for (int j = 0; j < 3; ++ j)
				scanf("%d",&q[i][j]);
		for (int i=0,l,r; i < k; ++ i)
		{
			scanf("%d%d",&l,&r);
			update(l,r,1,1,qn);
		}
		for (int i = 1; i <= m; ++ i)
			update(q[i][0],q[i][1],q[i][2]*quary(i,i,1,qn),1,an);
		for (int i = 1; i < n; ++ i)
			printf("%I64d ", a[i]+quary(i,i,1,an));
		printf("%I64d\n", a[n]+quary(n,n,1,an));
	}
}


#include <cstdio>
#define N 101000
typedef int LL;
int n, m, k;
struct Node
{
	int a, b;
	LL sum, inc;
	Node() {}
	Node(int _a, int _b): a(_a), b(_b), sum(0), inc(0) {}
	int middle() { return (a+b)>>1; }
} an[N*4], qn[N*4];
void build(int l, int r, int d, Node t[])
{
	if (l > r) return ;
	t[d] = Node(l,r);
	if (l == r) return ;
	int mid = t[d].middle();
	build(l,mid,d<<1,t);
	build(mid+1,r,(d<<1)+1,t);
}
void update(int fo, int to, int v, int d, Node t[])
{
	t[d].sum += (to-fo+1)*v;
	if (fo==t[d].a && t[d].b==to)
	{
		t[d].inc += v;
		return ;
	}
	int mid = t[d].middle();
	if (mid>=fo && mid<to)
	{
		update(fo,mid,v,d<<1,t);
		update(mid+1,to,v,(d<<1)+1,t);
	}
	else if (mid < fo)
	{
		update(fo,to,v,(d<<1)+1,t);
	}
	else if (mid >= to)
	{
		update(fo,to,v,d<<1,t);
	}
}
LL quary(int fo, int to, int d, Node t[])
{
	if (fo==t[d].a && to==t[d].b) return t[d].sum;
	int mid = t[d].middle();
	if (mid>=fo && mid<to) return quary(fo,mid,d<<1,t) + quary(mid+1,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid < fo) return quary(fo,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid >= to) return quary(fo,to,d<<1,t) + (to-fo+1)*t[d].inc;
}
LL q[N][3], a[N];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	while (scanf("%d%d%d",&n,&m,&k) != EOF)
	{
		build(1,n,1,an);
		build(1,n,1,qn);
		for (int i = 1; i <= n; ++ i)
			scanf("%d",&a[i]);
		for (int i = 1; i <= m; ++ i)
			for (int j = 0; j < 3; ++ j)
				scanf("%d",&q[i][j]);
		for (int i=0,l,r; i < k; ++ i)
		{
			scanf("%d%d",&l,&r);
			update(l,r,1,1,qn);
		}
		for (int i = 1; i <= m; ++ i)
			update(q[i][0],q[i][1],q[i][2]*quary(i,i,1,qn),1,an);
		for (int i = 1; i < n; ++ i)
			printf("%d ", a[i]+quary(i,i,1,an));
		printf("%d\n", a[n]+quary(n,n,1,an));
	}
}


#include <cstdio>
#define N 100005
typedef long long LL;
int n, m, k;
struct Node
{
	int a, b;
	LL sum, inc;
	Node() {}
	Node(int _a, int _b): a(_a), b(_b), sum(0), inc(0) {}
	int middle() { return (a+b)>>1; }
} an[N*4], qn[N*4];
void build(int l, int r, int d, Node t[])
{
	if (l > r) return ;
	t[d] = Node(l,r);
	if (l == r) return ;
	int mid = t[d].middle();
	build(l,mid,d<<1,t);
	build(mid+1,r,(d<<1)+1,t);
}
void update(int fo, int to, int v, int d, Node t[])
{
	t[d].sum += (to-fo+1)*v;
	if (fo==t[d].a && t[d].b==to)
	{
		t[d].inc += v;
		return ;
	}
	int mid = t[d].middle();
	if (mid>=fo && mid<to)
	{
		update(fo,mid,v,d<<1,t);
		update(mid+1,to,v,(d<<1)+1,t);
	}
	else if (mid < fo)
	{
		update(fo,to,v,(d<<1)+1,t);
	}
	else if (mid >= to)
	{
		update(fo,to,v,d<<1,t);
	}
}
LL quary(int fo, int to, int d, Node t[])
{
	if (fo==t[d].a && to==t[d].b) return t[d].sum;
	int mid = t[d].middle();
	if (mid>=fo && mid<to) return quary(fo,mid,d<<1,t) + quary(mid+1,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid < fo) return quary(fo,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid >= to) return quary(fo,to,d<<1,t) + (to-fo+1)*t[d].inc;
}
LL q[N][3], a[N];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	while (scanf("%d%d%d",&n,&m,&k) != EOF)
	{
		build(1,n,1,an);
		build(1,m,1,qn);
		for (int i = 1; i <= n; ++ i)
			scanf("%d",&a[i]);
		for (int i = 1; i <= m; ++ i)
			for (int j = 0; j < 3; ++ j)
				scanf("%d",&q[i][j]);
		for (int i=0,l,r; i < k; ++ i)
		{
			scanf("%d%d",&l,&r);
			update(l,r,1,1,qn);
		}
		for (int i = 1; i <= m; ++ i)
			update(q[i][0],q[i][1],q[i][2]*quary(i,i,1,qn),1,an);
		for (int i = 1; i < n; ++ i)
			printf("%I64d ", a[i]+quary(i,i,1,an));
		printf("%I64d\n", a[n]+quary(n,n,1,an));
	}
}


#include <cstdio>
#define N 100005
typedef int LL;
int n, m, k;
struct Node
{
	int a, b;
	LL sum, inc;
	Node() {}
	Node(int _a, int _b): a(_a), b(_b), sum(0), inc(0) {}
	int middle() { return (a+b)>>1; }
} an[N*4], qn[N*4];
void build(int l, int r, int d, Node t[])
{
	if (l > r) return ;
	t[d] = Node(l,r);
	if (l == r) return ;
	int mid = t[d].middle();
	build(l,mid,d<<1,t);
	build(mid+1,r,(d<<1)+1,t);
}
void update(int fo, int to, int v, int d, Node t[])
{
	t[d].sum += (to-fo+1)*v;
	if (fo==t[d].a && t[d].b==to)
	{
		t[d].inc += v;
		return ;
	}
	int mid = t[d].middle();
	if (mid>=fo && mid<to)
	{
		update(fo,mid,v,d<<1,t);
		update(mid+1,to,v,(d<<1)+1,t);
	}
	else if (mid < fo)
	{
		update(fo,to,v,(d<<1)+1,t);
	}
	else if (mid >= to)
	{
		update(fo,to,v,d<<1,t);
	}
}
LL quary(int fo, int to, int d, Node t[])
{
	if (fo==t[d].a && to==t[d].b) return t[d].sum;
	int mid = t[d].middle();
	if (mid>=fo && mid<to) return quary(fo,mid,d<<1,t) + quary(mid+1,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid < fo) return quary(fo,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid >= to) return quary(fo,to,d<<1,t) + (to-fo+1)*t[d].inc;
}
LL q[N][3], a[N];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	while (scanf("%d%d%d",&n,&m,&k) != EOF)
	{
		build(1,n,1,an);
		build(1,m,1,qn);
		for (int i = 1; i <= n; ++ i)
			scanf("%d",&a[i]);
		for (int i = 1; i <= m; ++ i)
			for (int j = 0; j < 3; ++ j)
				scanf("%d",&q[i][j]);
		for (int i=0,l,r; i < k; ++ i)
		{
			scanf("%d%d",&l,&r);
			update(l,r,1,1,qn);
		}
		for (int i = 1; i <= m; ++ i)
			update(q[i][0],q[i][1],q[i][2]*quary(i,i,1,qn),1,an);
		for (int i = 1; i < n; ++ i)
			printf("%d ", a[i]+quary(i,i,1,an));
		printf("%d\n", a[n]+quary(n,n,1,an));
	}
}


#include <cstdio>
#define N 101000
typedef int LL;
int n, m, k;
struct Node
{
	int a, b;
	LL sum, inc;
	Node() {}
	Node(int _a, int _b): a(_a), b(_b), sum(0), inc(0) {}
	int middle() { return (a+b)>>1; }
} an[N*4], qn[N*4];
void build(int l, int r, int d, Node t[])
{
	if (l > r) return ;
	t[d] = Node(l,r);
	if (l == r) return ;
	int mid = t[d].middle();
	build(l,mid,d<<1,t);
	build(mid+1,r,(d<<1)+1,t);
}
void update(int fo, int to, int v, int d, Node t[])
{
	t[d].sum += (to-fo+1)*v;
	if (fo==t[d].a && t[d].b==to)
	{
		t[d].inc += v;
		return ;
	}
	int mid = t[d].middle();
	if (mid>=fo && mid<to)
	{
		update(fo,mid,v,d<<1,t);
		update(mid+1,to,v,(d<<1)+1,t);
	}
	else if (mid < fo)
	{
		update(fo,to,v,(d<<1)+1,t);
	}
	else if (mid >= to)
	{
		update(fo,to,v,d<<1,t);
	}
}
LL quary(int fo, int to, int d, Node t[])
{
	if (fo==t[d].a && to==t[d].b) return t[d].sum;
	int mid = t[d].middle();
	if (mid>=fo && mid<to) return quary(fo,mid,d<<1,t) + quary(mid+1,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid < fo) return quary(fo,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid >= to) return quary(fo,to,d<<1,t) + (to-fo+1)*t[d].inc;
}
LL q[N][3], a[N];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	while (scanf("%d%d%d",&n,&m,&k) != EOF)
	{
		build(1,n,1,an);
		build(1,n,1,qn);
		for (int i = 1; i <= n; ++ i)
			scanf("%d",&a[i]);
		for (int i = 1; i <= m; ++ i)
			for (int j = 0; j < 3; ++ j)
				scanf("%d",&q[i][j]);
		for (int i=0,l,r; i < k; ++ i)
		{
			scanf("%d%d",&l,&r);
			update(l,r,1,1,qn);
		}
		for (int i = 1; i <= m; ++ i)
			update(q[i][0],q[i][1],q[i][2]*quary(i,i,1,qn),1,an);
		for (int i = 1; i < n; ++ i)
			printf("%I64d ", a[i]+quary(i,i,1,an));
		printf("%I64d\n", a[n]+quary(n,n,1,an));
	}
}


#include <cstdio>
#define N 100005
typedef long long LL;
int n, m, k;
struct Node
{
	int a, b;
	int middle() { return (a+b)>>1; }
	LL sum, inc;
	Node() {}
	Node(int _a, int _b): a(_a), b(_b), sum(0), inc(0) {}
} an[N*4], qn[N*4];
void build(int l, int r, int d, Node t[])
{
	if (l > r) return ;
	t[d] = Node(l,r);
	if (l == r) return ;
	int mid = t[d].middle();
	build(l,mid,d<<1,t);
	build(mid+1,r,(d<<1)+1,t);
}
void update(int fo, int to, LL v, int d, Node t[])
{
	t[d].sum += (to-fo+1)*v;
	if (fo==t[d].a && t[d].b==to)
	{
		t[d].inc += v;
		return ;
	}
	int mid = t[d].middle();
	if (mid>=fo && mid<to)
	{
		update(fo,mid,v,d<<1,t);
		update(mid+1,to,v,(d<<1)+1,t);
	}
	else if (mid < fo)
	{
		update(fo,to,v,(d<<1)+1,t);
	}
	else if (mid >= to)
	{
		update(fo,to,v,d<<1,t);
	}
}
LL quary(int fo, int to, int d, Node t[])
{
	if (fo==t[d].a && to==t[d].b) return t[d].sum;
	int mid = t[d].middle();
	if (mid>=fo && mid<to) return quary(fo,mid,d<<1,t) + quary(mid+1,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid < fo) return quary(fo,to,(d<<1)+1,t) + (to-fo+1)*t[d].inc;
	else if (mid >= to) return quary(fo,to,d<<1,t) + (to-fo+1)*t[d].inc;
}
LL q[N][3], a[N];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	while (scanf("%d%d%d",&n,&m,&k) != EOF)
	{
		build(1,n,1,an);
		build(1,m,1,qn);
		for (int i = 1; i <= n; ++ i)
			scanf("%d",&a[i]);
		for (int i = 1; i <= m; ++ i)
			for (int j = 0; j < 3; ++ j)
				scanf("%d",&q[i][j]);
		for (int i=0,l,r; i < k; ++ i)
		{
			scanf("%d%d",&l,&r);
			update(l,r,1,1,qn);
		}
		for (int i = 1; i <= m; ++ i)
			update(q[i][0],q[i][1],q[i][2]*quary(i,i,1,qn),1,an);
		for (int i = 1; i < n; ++ i)
			printf("%I64d ", a[i]+quary(i,i,1,an));
		printf("%I64d\n", a[n]+quary(n,n,1,an));
	}
}


#include <iostream>
using namespace std;
#include <cstdio>
#include <cstdlib>
#define MAX 100100

__int64 sum[MAX<<2];
__int64 add[MAX<<2];

void pushdown(int curr, int  m)
{
      if(add[curr])//add不为0表示，此add加到了这一层之下的没加
      {
            add[2*curr] += add[curr];
            add[2*curr+1] += add[curr];
            sum[2*curr] += add[curr]*(m-m/2);

            sum[2*curr+1] += add[curr]*(m/2);
            add[curr] = 0;
      }
}

void create(int beg, int end, int curr)
{
        add[curr] = 0;
        if(beg == end)
        {
              scanf("%I64d",&sum[curr]);
              return ;
        }
        int mid = (beg + end)/2;
        create(beg, mid, 2*curr);
        create(mid+1, end, 2*curr+1);
        sum[curr] = sum[2*curr] + sum[2*curr+1];
}

__int64 query(int left, int right, int beg, int end, int curr)
{
         if(left <= beg && end <= right)
         {
                 return sum[curr];
         }
         pushdown(curr,end-beg+1);
         //查询的时候也是一样的，如果查询到当前的区间的编号时
         //  没有pushdown的操作时，查询到此时，必然会进入左右的节点进行更新，
         //那么左右节点的所得到的查询值不会正确
         int mid = (beg + end)/2;
         __int64 ret = 0;
         if(left <= mid)
         ret += query(left, right, beg, mid, 2*curr);
         if(mid < right)
         ret += query(left, right, mid+1, end, 2*curr+1);
         return ret;
}

void update(int a, int b, int c, int beg, int end, int curr)
{
         if(a <= beg && end <= b)
         {
               sum[curr] += (__int64)c*(end - beg + 1);
               add[curr] += c;
               return ;
         }
         pushdown(curr, end-beg+1);//向左右孩子节点进行更新
         //  当查询到该区间时，该区间的编号是curr
         //  如果不把信息传递给直接点，那么再对本层更新时
         //  即 sum[curr] = sum[2*curr] + sum[2*curr+1];一定会出现错误
         int mid = (beg + end)/2;
         if(a <= mid)
         update(a, b, c, beg, mid, 2*curr);
         if(mid < b)
         update(a, b, c, mid+1, end, 2*curr+1);
         sum[curr] = sum[2*curr] + sum[2*curr+1];//向父亲节点进行更新
}
int aa[100100][3],a[100100];
int c[100100]={0},d[100100]={0};
int N,M,K;
int main()
{
      scanf("%d%d%d",&N,&M,&K);
      for(int i = 0;i < N;i++) scanf("%d",&a[i]);
      for(int i = 0;i < M;i++)
      {
          scanf("%d%d%d",&aa[i][0],&aa[i][1],&aa[i][2]);
      }
      for(int i = 0;i < K;i++)
      {
          int x,y;
          scanf("%d%d",&x,&y);
          c[y] ++;
          if(x!=1) c[x-1] -= 1;
      }
      for(int i = N;i >= 1;i--) c[i]+=c[i+1];
      for(int i = 0;i < N;i++)
      {
          d[aa[i][1]] += aa[i][2]*c[i+1];
          if(aa[i][0]!=1) d[aa[i][0]-1] -= aa[i][2]*c[i+1];
      }
      for(int i = N;i >= 1;i--) d[i]+=d[i+1];
      for(int i = 1;i <= N;i++)
      {
          printf(i==1?"%d":" %d",d[i]+a[i-1]);
      }
      printf("\n");
      ///system("pause");
}


#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include <cmath>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<fstream>
#define pb push_back
#define limit 100000
#define mp make_pair
#define ss second.second
#define sf second.first
using namespace std;
long long a[limit+5],b[limit+5][3];
int main(){
    long long n,m,k;
    cin>>n>>m>>k;
        int arr[n+5];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        arr[i]=0;
    }
    int c[m+5];
    for(int i=1;i<=m;i++){
        cin>>b[i][0]>>b[i][1]>>b[i][2];
        c[i]=0;
    }
    for(int i=1;i<=k;i++){
        int x,y;
        cin>>x>>y;
        c[x]++;
        c[y+1]--;
    }
    int l=0;;
    for(int i=1;i<=m;i++){
        c[i]+=l;
        l=c[i];
        b[i][2]*=c[i];
    }
    l=0;

    for(int i=1;i<=m;i++){
        arr[b[i][0]]+=b[i][2];
        arr[b[i][1]+1]-=b[i][2];
    }
    for(int i=1;i<=n;i++){
        arr[i]+=l;
        l=arr[i];
        cout<<arr[i]+a[i]<<" ";
    }
}


#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include <cmath>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<fstream>
#define pb push_back
#define limit 100000
#define mp make_pair
#define ss second.second
#define sf second.first
using namespace std;
int a[limit+1],b[limit+1][4];
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>b[i][0]>>b[i][1]>>b[i][2];
        b[i][3]=0;
    }
    int x,y;
    for(int i=1;i<=k;i++){
        cin>>x>>y;
        for(int i=x;i<=y;i++){
            b[i][3]++;
        }
    }
    for(int i=1;i<=m;i++){
        for(int j=b[i][0];j<=b[i][1];j++){
            a[j]+=b[i][3]*b[i][2];
        }
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<" ";
    }
}


#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include <cmath>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<fstream>
#define pb push_back
#define limit 100000
#define mp make_pair
#define ss second.second
#define sf second.first
using namespace std;
long long a[limit+5],b[limit+5][3];
int main(){
    long long n,m,k;
    cin>>n>>m>>k;
        long long arr[n+5];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        arr[i]=0;
    }
    long long c[m+5];
    for(int i=1;i<=m;i++){
        cin>>b[i][0]>>b[i][1]>>b[i][2];
        c[i]=0;
    }
    for(int i=1;i<=k;i++){
        int x,y;
        cin>>x>>y;
        c[x]++;
        c[y+1]--;
    }
    long long l=0;;
    for(int i=1;i<=m;i++){
        c[i]+=l;
        l=c[i];
        b[i][2]*=c[i];
    }
    l=0;

    for(int i=1;i<=m;i++){
        arr[b[i][0]]+=b[i][2];
        arr[b[i][1]+1]-=b[i][2];
    }
    for(int i=1;i<=n;i++){
        arr[i]+=l;
        l=arr[i];
        cout<<((long long)arr[i]+a[i])<<" ";
    }
}


#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include <cmath>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<fstream>
#define pb push_back
#define limit 100000
#define mp make_pair
#define ss second.second
#define sf second.first
using namespace std;
long long a[limit+1],b[limit+1][4];
int main(){
    long long n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>b[i][0]>>b[i][1]>>b[i][2];
        b[i][3]=0;
    }
    long long x,y;
    for(int i=1;i<=k;i++){
        cin>>x>>y;
        for(int i=x;i<=y;i++){
            b[i][3]++;
        }
    }
    for(int i=1;i<=m;i++){
        for(int j=b[i][0];j<=b[i][1];j++){
            a[j]+=b[i][3]*b[i][2];
        }
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<" ";
    }
}


#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include <cmath>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<fstream>
#define pb push_back
#define limit 100000
#define mp make_pair
#define ss second.second
#define sf second.first
using namespace std;
long long a[limit+5],b[limit+5][3];
int main(){
    long long n,m,k;
    cin>>n>>m>>k;
        int arr[n+5];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        arr[i]=0;
    }
    int c[m+5];
    for(int i=1;i<=m;i++){
        cin>>b[i][0]>>b[i][1]>>b[i][2];
        c[i]=0;
    }
    for(int i=1;i<=k;i++){
        int x,y;
        cin>>x>>y;
        c[x]++;
        c[y+1]--;
    }
    int l=0;

    for(int i=1;i<=m;i++){
        c[i]+=l;
        l=c[i];
        b[i][2]*=c[i];
    }
    l=0;

    for(int i=1;i<=m;i++){
        arr[b[i][0]]+=b[i][2];
        arr[b[i][1]+1]-=b[i][2];
    }
    for(int i=1;i<=n;i++){
        arr[i]+=l;
        l=arr[i];
        cout<<arr[i]+a[i]<<" ";
    }
}


#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include <cmath>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<fstream>
#define pb push_back
#define limit 100000
#define mp make_pair
#define ss second.second
#define sf second.first
using namespace std;
long long a[limit+5],b[limit+5][3];
int main(){
    long long n,m,k;
    cin>>n>>m>>k;
    long long arr[n+5];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        arr[i]=0;
    }
    long long c[m+5];
    for(int i=1;i<=m;i++){
        cin>>b[i][0]>>b[i][1]>>b[i][2];
        c[i]=0;
    }
    for(int i=1;i<=k;i++){
        long long x,y;
        cin>>x>>y;
        c[x]++;
        c[y+1]--;
    }
    long long l=0;;
    for(int i=1;i<=m;i++){
        c[i]+=l;
        l=c[i];
        b[i][2]*=c[i];
    }
    l=0;

    for(int i=1;i<=m;i++){
        arr[b[i][0]]+=b[i][2];
        arr[b[i][1]+1]-=b[i][2];
    }
    for(int i=1;i<=n;i++){
        arr[i]+=l;
        l=arr[i];
        cout<<arr[i]+a[i]<<" ";
    }
}


#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include <cmath>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<fstream>
#define pb push_back
#define limit 100000
#define mp make_pair
#define ss second.second
#define sf second.first
using namespace std;
long long a[limit+5],b[limit+5][3];
int main(){
    long long n,m,k;
    cin>>n>>m>>k;
        int arr[n+5];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        arr[i]=0;
    }
    int c[m+5];
    for(int i=1;i<=m;i++){
        cin>>b[i][0]>>b[i][1]>>b[i][2];
        c[i]=0;
    }
    for(int i=1;i<=k;i++){
        int x,y;
        cin>>x>>y;
        c[x]++;
        c[y+1]--;
    }
    int l=0;;
    for(int i=1;i<=m;i++){
        c[i]+=l;
        l=c[i];
        b[i][2]*=c[i];
    }
    l=0;

    for(int i=1;i<=m;i++){
        arr[b[i][0]]+=b[i][2];
        arr[b[i][1]+1]-=b[i][2];
    }
    for(int i=1;i<=n;i++){
        arr[i]+=l;
        l=arr[i];
        cout<<arr[i]+a[i]<<" ";
    }

}


#include <iostream>
#include <fstream>
#define In "date.in"
#define Out "date.out"
#define Nmax 100004
using namespace std;
struct str
{
    int st,dr;long val;
};
long long a[Nmax],push[Nmax],pop[Nmax];
str op[Nmax];
int nr[Nmax],nrp[Nmax];
int n,m,k;
inline void Citire()
{
    ifstream fin(In);
    cin>>n>>m>>k;
    int i,x,y;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=m;i++)
        cin>>op[i].st>>op[i].dr>>op[i].val;
    for(i=1;i<=k;i++)
    {
        cin>>x>>y;
        nr[x]++;
        nrp[y+1]++;
    }
    x = 0;
    for(i=1;i<=m;i++)
    {
        x = x + nr[i]-nrp[i];
        push[op[i].st] +=op[i].val*x;
        pop[op[i].dr+1]+= op[i].val*x;
    }
}

inline void Afisare()
{
    int i;
    ofstream fout(Out);
    long long aux = 0;
    for(i=1;i<=n;i++)
    {
        aux = aux+push[i]-pop[i];
        cout<<a[i]+aux<<" ";
    }
}

int main()
{
    Citire();
    Afisare();
    return 0;
}


#include <iostream>
#include <fstream>
#define In "date.in"
#define Out "date.out"
#define Nmax 100004
using namespace std;
struct str
{
    long long st,dr,val;
};
long long a[Nmax],push[Nmax],pop[Nmax],n,m,k,nr[Nmax],nrp[Nmax];
str op[Nmax];
inline void Citire()
{
    ifstream fin(In);
    cin>>n>>m>>k;
    long long i,x,y;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=m;i++)
        cin>>op[i].st>>op[i].dr>>op[i].val;
    for(i=1;i<=k;i++)
    {
        cin>>x>>y;
        nr[x]++;
        nrp[y+1]++;
    }
    x = 0;
    for(i=1;i<=m;i++)
    {
        x = x + nr[i]-nrp[i];
        push[op[i].st] +=op[i].val*x;
        pop[op[i].dr+1]+= op[i].val*x;
    }
}

inline void Afisare()
{
    long long i;
    ofstream fout(Out);
    long long aux = 0;
    for(i=1;i<=n;i++)
    {
        aux = aux+push[i]-pop[i];
        cout<<(a[i]*1LL+aux*1LL)*1LL<<" ";
    }
}

int main()
{
    Citire();
    Afisare();
    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#define In "date.in"
#define Out "date.out"
#define Nmax 100004
using namespace std;
struct str
{
    int st,dr;long val;
};
long long a[Nmax],push[Nmax],pop[Nmax];
str op[Nmax];
int n,m,k;
inline void Citire()
{
    ifstream fin(In);
    cin>>n>>m>>k;
    int i,j,x,y;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=m;i++)
        cin>>op[i].st>>op[i].dr>>op[i].val;
    for(i=1;i<=k;i++)
    {
        cin>>x>>y;
        for(j=x;j<=y;j++)
        {
            push[op[j].st] +=op[j].val;
            pop[op[j].dr+1]+= op[j].val;
        }
    }
}

inline void Afisare()
{
    int i;
    ofstream fout(Out);
    long long aux = 0;
    for(i=1;i<=n;i++)
    {
        aux = aux+push[i]-pop[i];
        cout<<a[i]+aux<<" ";
    }
}

int main()
{
    Citire();
    Afisare();
    return 0;
}


#include <iostream>
#include <fstream>
#define In "date.in"
#define Out "date.out"
#define Nmax 100004
using namespace std;
struct str
{
    long long st,dr,val;
};
long long a[Nmax],push[Nmax],pop[Nmax],n,m,k,nr[Nmax],nrp[Nmax];
str op[Nmax];
inline void Citire()
{
    ifstream fin(In);
    cin>>n>>m>>k;
    long long i,x,y;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=m;i++)
        cin>>op[i].st>>op[i].dr>>op[i].val;
    for(i=1;i<=k;i++)
    {
        cin>>x>>y;
        nr[x]++;
        nrp[y+1]++;
    }
    x = 0;
    for(i=1;i<=m;i++)
    {
        x = x + nr[i]-nrp[i];
        push[op[i].st] +=op[i].val*x;
        pop[op[i].dr+1]+= op[i].val*x;
    }
}

inline void Afisare()
{
    long long i;
    ofstream fout(Out);
    long long aux = 0;
    for(i=1;i<=n;i++)
    {
        aux = aux+push[i]-pop[i];
        cout<<long long(a[i]+aux)<<" ";
    }
}

int main()
{
    Citire();
    Afisare();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
long long n,m,k;
long long a[100010];
struct haha
{
    long long l;
    long long r;
    long long d;
}ha[100010];
long long b1[100010],e[100010],b[100010];
int main()
{
    while(scanf("%I64d%I64d%I64d",&n,&m,&k)!=EOF)
    {
        memset(b1,0,sizeof(b1));
        memset(e,0,sizeof(e));
       for(int i=1;i<=n;i++)
       {
           scanf("%I64d",&a[i]);
       }
       for(int i=1;i<=m;i++)
       {
           scanf("%I64d%I64d%I64d",&ha[i].l,&ha[i].r,&ha[i].d);
       }
       for(int i=0;i<k;i++)
       {
           int x,y;
           scanf("%d%d",&x,&y);
           for(int j=x;j<=y;j++)
           {
               b1[ha[j].l]+=ha[j].d;
               e[ha[j].r]+=ha[j].d;
           }
       }
       long long w=0;
       for(int i=1;i<=n;i++)
       {
           w+=b1[i];
           b[i]=w;
           w-=e[i];
       }
       for(int i=1;i<=n-1;i++)
       {
           printf("%I64d ",a[i]+b[i]);
       }
       printf("%I64d\n",a[n]+b[n]);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
long long n,m,k;
long long a[100010];
struct haha
{
    long long l;
    long long r;
    long long d;
}ha[100010];
int main()
{
    while(scanf("%I64dI64%I64",&n,&m,&k)!=EOF)
    {
       for(int i=0;i<n;i++)
       {
           scanf("%I64d",&a[i]);
       }
       for(int i=0;i<m;i++)
       {
           scanf("%I64d%I64d%I64d",&ha[i].l,&ha[i].r,&ha[i].d);
       }
       for(int i=0;i<k;i++)
       {
           int x,y;
           scanf("%d%d",&x,&y);
           for(int j=x;j<=y;j++)
           {
               for(int k=ha[j].l;k<=ha[j].r;k++)
               {
                   a[k]+=ha[j].d;
               }
           }
       }
       for(int i=0;i<n-1;i++)
       {
           printf("%I64d ",a[i]);
       }
       printf("%I64d\n",a[n-1]);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
long long n,m,k;
long long a[100010];
struct haha
{
    long long l;
    long long r;
    long long d;
}ha[100010];
long long b1[100010],e[100010],b[100010];
int main()
{
    while(scanf("%I64d%I64d%I64d",&n,&m,&k)!=EOF)
    {
        memset(b1,0,sizeof(b1));
        memset(e,0,sizeof(e));
       for(int i=1;i<=n;i++)
       {
           scanf("%I64d",&a[i]);
       }
       for(int i=1;i<=m;i++)
       {
           scanf("%I64d%I64d%I64d",&ha[i].l,&ha[i].r,&ha[i].d);
       }
       for(int i=0;i<k;i++)
       {
           int x,y;
           scanf("%d%d",&x,&y);
           for(int j=x;j<=y;j++)
           {
               b1[ha[j].l]+=ha[j].d;
               e[ha[j].r]+=ha[j].d;
           }
       }
       long long w=0;
       for(int i=1;i<=n;i++)
       {
           w+=b1[i];
           b[i]=w;
           w-=e[i];
       }
       for(int i=1;i<=n-1;i++)
       {
           printf("%I64d ",a[i]+b[i]);
       }
       printf("%I64d\n",a[n]+b[n]);
    }
    return 0;


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
long long n,m,k;
long long a[100010];
struct haha
{
    long long l;
    long long r;
    long long d;
}ha[100010];
long long b1[100010],e[100010],b[100010];
int main()
{
    while(scanf("%I64d%I64d%I64d",&n,&m,&k)!=EOF)
    {
        memset(b1,0,sizeof(b1));
        memset(e,0,sizeof(e));
       for(int i=1;i<=n;i++)
       {
           scanf("%I64d",&a[i]);
       }
       for(int i=1;i<=m;i++)
       {
           scanf("%I64d%I64d%I64d",&ha[i].l,&ha[i].r,&ha[i].d);
       }
       for(int i=0;i<k;i++)
       {
           int x,y;
           scanf("%d%d",&x,&y);
           for(int j=x;j<=y;j++)
           {
               b1[ha[j].l]+=ha[j].d;
               e[ha[j].r]+=ha[j].d;
           }
       }
       int w=0;
       for(int i=1;i<=n;i++)
       {
           w+=b1[i];
           b[i]=w;
           w-=e[i];
       }
       for(int i=1;i<=n-1;i++)
       {
           printf("%I64d ",a[i]+b[i]);
       }
       printf("%I64d\n",a[n]+b[n]);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
long long n,m,k;
long long a[100010];
struct haha
{
    long long l;
    long long r;
    long long d;
}ha[100010];
int main()
{
    while(scanf("%I64d%I64d%I64d",&n,&m,&k)!=EOF)
    {
       for(int i=1;i<=n;i++)
       {
           scanf("%I64d",&a[i]);
       }
       for(int i=1;i<=m;i++)
       {
           scanf("%I64d%I64d%I64d",&ha[i].l,&ha[i].r,&ha[i].d);
       }
       for(int i=0;i<k;i++)
       {
           int x,y;
           scanf("%d%d",&x,&y);
           for(int j=x;j<=y;j++)
           {
               for(int k=ha[j].l;k<=ha[j].r;k++)
               {
                   a[k]+=ha[j].d;
               }
           }
       }
       for(int i=1;i<=n-1;i++)
       {
           printf("%I64d ",a[i]);
       }
       printf("%I64d\n",a[n]);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#define mod 1000000007
using namespace std;
long long a[100005],s[100005],t[100005],l[100005],r[100005],d[100005];
long long n,m,k,x,y;
int main()
{
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%I64d",&a[i]);
    }
    for(int i=1;i<=m;i++)
    {
        scanf("%I64d%I64d%I64d",&l[i],&r[i],&d[i]);
    }
    for(int i=1;i<=k;i++)
    {
        scanf("%d%d",&x,&y);
        t[x]++;
        t[y+1]--;
    }
    long long p=0;
    for(int i=1;i<=m;i++)
    {
        p+=t[i];
        d[i]*=p;
    }
    for(int i=1;i<=m;i++)
    {
        s[l[i]]+=d[i];
        s[r[i]+1]-=d[i];
    }
    p=0;
    for(int i=1;i<=n;i++)
    {
        p+=s[i];
        s[i]=p;
    }
    for(int i=1;i<n;i++)
    {
        printf("%I64d ",a[i]+s[i]);
    }
    printf("%I64d\n",a[n]+s[n]);
    return 0;
}


//DER.......
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<functional>
#include<math.h>
#include<assert.h>
#include<stdarg.h>
#include<time.h>
#include<limits.h>
#include<ctype.h>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<iostream>
#include<sstream>
using namespace std;

// #defines
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define LPI(i,n) for(int i=0;i<(n);i++)
#define LPI1(i,a,b) for(int i=(a);i<=(b);i++)
#define LPIL(i,x) for(int i=0;x[i];i++)
#define LPD(i,n) for(int i=(n)-1;i>=0;i--)
#define LPD1(i,a,b) for(int i=(a);i>=(b);i--)
#define I(x) scanf("%d",&x)
#define RI(x) int x;I(x)
#define II(x,y) scanf("%d%d",&x,&y)
#define RII(x,y) int x,y;II(x,y)
#define III(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define RIII(x,y,z) int x,y,z;III(x,y,z)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define CASET int ___T,cas=1;scanf("%d ",&___T);while(___T--)
#define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
#define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define F first
#define S second
#ifdef ONLINE_JUDGE
#define FILEIO(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define FILEIOS freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define FILEIO(x) ;
#define FILEIOS ;
#endif
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
LL A[100005];
int B[100005][4];
int main(){
    RIII(n,m,k);
    LPI(i,n)
    {
        RI(x);
        A[i+1]=x;
    }
    LPI(i,m)
    {
        RIII(l,r,d);
        B[i+1][0]=l;B[i+1][1]=r;B[i+1][2]=d;
    }
    LPI(i,k)
    {
        RII(x,y);
        LPI1(j,x,y)
        {
            LPI1(v,B[j][0],B[j][1])
            A[v]+=B[j][2];
        }
    }
    LPI(i,n)
    {
        cout<<A[i+1]<<" ";
    }

    return 0;
}


//DER.......
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<functional>
#include<math.h>
#include<assert.h>
#include<stdarg.h>
#include<time.h>
#include<limits.h>
#include<ctype.h>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<iostream>
#include<sstream>
using namespace std;

// #defines
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define LPI(i,n) for(int i=0;i<(n);i++)
#define LPI1(i,a,b) for(int i=(a);i<=(b);i++)
#define LPIL(i,x) for(int i=0;x[i];i++)
#define LPD(i,n) for(int i=(n)-1;i>=0;i--)
#define LPD1(i,a,b) for(int i=(a);i>=(b);i--)
#define I(x) scanf("%d",&x)
#define RI(x) int x;I(x)
#define II(x,y) scanf("%d%d",&x,&y)
#define RII(x,y) int x,y;II(x,y)
#define III(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define RIII(x,y,z) int x,y,z;III(x,y,z)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define CASET int ___T,cas=1;scanf("%d ",&___T);while(___T--)
#define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
#define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define F first
#define S second
#ifdef ONLINE_JUDGE
#define FILEIO(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define FILEIOS freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define FILEIO(x) ;
#define FILEIOS ;
#endif
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
LL A[100005];
int B[100005][4];
LL s[100005];
int main(){
    RIII(n,m,k);
    LPI(i,n)
    {
        RI(x);
        A[i+1]=x;
    }
    LPI(i,m)
    {
        RIII(l,r,d);
        B[i+1][0]=l;B[i+1][1]=r;B[i+1][2]=d;
    }
    MS0(s);
    LPI(i,k)
    {
        RII(x,y);
        LPI1(j,x,y)
        {
            s[B[j][0]]+=B[j][2];
            s[B[j][1]+1]-=B[j][2];
        }
    }
    LPI(i,n)
    {

        cout<<(A[i+1]+s[i+1])<<" ";
        s[i+2]=s[i+2]+s[i+1];
    }

    return 0;
}


//DER.......
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<functional>
#include<math.h>
#include<assert.h>
#include<stdarg.h>
#include<time.h>
#include<limits.h>
#include<ctype.h>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<iostream>
#include<sstream>
using namespace std;

// #defines
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define LPI(i,n) for(int i=0;i<(n);i++)
#define LPI1(i,a,b) for(int i=(a);i<=(b);i++)
#define LPIL(i,x) for(int i=0;x[i];i++)
#define LPD(i,n) for(int i=(n)-1;i>=0;i--)
#define LPD1(i,a,b) for(int i=(a);i>=(b);i--)
#define I(x) scanf("%d",&x)
#define RI(x) int x;I(x)
#define II(x,y) scanf("%d%d",&x,&y)
#define RII(x,y) int x,y;II(x,y)
#define III(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define RIII(x,y,z) int x,y,z;III(x,y,z)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define CASET int ___T,cas=1;scanf("%d ",&___T);while(___T--)
#define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
#define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define F first
#define S second
#ifdef ONLINE_JUDGE
#define FILEIO(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define FILEIOS freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define FILEIO(x) ;
#define FILEIOS ;
#endif
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
LL A[100005];
int B[100005][4];
long s[100005];
int main(){
    RIII(n,m,k);
    LPI(i,n)
    {
        RI(x);
        A[i+1]=x;
    }
    LPI(i,m)
    {
        RIII(l,r,d);
        B[i+1][0]=l;B[i+1][1]=r;B[i+1][2]=d;
    }
    MS0(s);
    LPI(i,k)
    {
        RII(x,y);
        LPI1(j,x,y)
        {
            s[B[j][0]]+=B[j][2];
            s[B[j][1]+1]-=B[j][2];
        }
    }
    LPI(i,n)
    {

        cout<<(A[i+1]+s[i+1])<<" ";
        s[i+2]=s[i+2]+s[i+1];
    }

    return 0;
}


//DER.......
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<functional>
#include<math.h>
#include<assert.h>
#include<stdarg.h>
#include<time.h>
#include<limits.h>
#include<ctype.h>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<iostream>
#include<sstream>
using namespace std;

// #defines
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define LPI(i,n) for(int i=0;i<(n);i++)
#define LPI1(i,a,b) for(int i=(a);i<=(b);i++)
#define LPIL(i,x) for(int i=0;x[i];i++)
#define LPD(i,n) for(int i=(n)-1;i>=0;i--)
#define LPD1(i,a,b) for(int i=(a);i>=(b);i--)
#define I(x) scanf("%d",&x)
#define RI(x) int x;I(x)
#define II(x,y) scanf("%d%d",&x,&y)
#define RII(x,y) int x,y;II(x,y)
#define III(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define RIII(x,y,z) int x,y,z;III(x,y,z)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define CASET int ___T,cas=1;scanf("%d ",&___T);while(___T--)
#define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
#define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define F first
#define S second
#ifdef ONLINE_JUDGE
#define FILEIO(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define FILEIOS freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define FILEIO(x) ;
#define FILEIOS ;
#endif
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
struct node
{
    long l;
    long r;
    long d;
};
LL A[100005];
node B[100005];
LL s[100005];
long s1[10005];

int main(){

    RIII(n,m,k);
    LPI(i,n)
    {
        RI(x);
        A[i+1]=x;
    }
    MS0(s);
    LPI(i,m)
    {
        RIII(l,r,d);
        B[i+1]={l,r,d};
    }
    MS0(s1);
    LPI(i,k)
    {
        RII(x,y);
        s1[x]++;
        s1[y+1]--;
    }
    LPI(i,m)
    {
        if(s1[i+1]>100000)
        cout<<"s";
        s[B[i+1].l]+=s1[i+1]*B[i+1].d;
        s[B[i+1].r+1]-=s1[i+1]*B[i+1].d;
        s1[i+2]+=s1[i+1];
    }
    LPI(i,n)
    {

        cout<<(A[i+1]+s[i+1])<<" ";
        s[i+2]=s[i+2]+s[i+1];

    }

    return 0;
}


//DER.......
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<functional>
#include<math.h>
#include<assert.h>
#include<stdarg.h>
#include<time.h>
#include<limits.h>
#include<ctype.h>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<iostream>
#include<sstream>
using namespace std;

// #defines
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define LPI(i,n) for(int i=0;i<(n);i++)
#define LPI1(i,a,b) for(int i=(a);i<=(b);i++)
#define LPIL(i,x) for(int i=0;x[i];i++)
#define LPD(i,n) for(int i=(n)-1;i>=0;i--)
#define LPD1(i,a,b) for(int i=(a);i>=(b);i--)
#define I(x) scanf("%d",&x)
#define RI(x) int x;I(x)
#define II(x,y) scanf("%d%d",&x,&y)
#define RII(x,y) int x,y;II(x,y)
#define III(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define RIII(x,y,z) int x,y,z;III(x,y,z)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define CASET int ___T,cas=1;scanf("%d ",&___T);while(___T--)
#define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
#define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define F first
#define S second
#ifdef ONLINE_JUDGE
#define FILEIO(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define FILEIOS freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define FILEIO(x) ;
#define FILEIOS ;
#endif
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
struct node
{
    long l;
    long r;
    long d;
};
LL A[100005];
node B[100005];
LL s[100005];
LL s1[10005];

int main(){

    RIII(n,m,k);
    LPI(i,n)
    {
        RI(x);
        A[i+1]=x;
    }
    MS0(s);
    LPI(i,m)
    {
        RIII(l,r,d);
        B[i+1]={l,r,d};
    }
    MS0(s1);
    LPI(i,k)
    {
        RII(x,y);
        s1[x]+=1;
        s1[y+1]-=1;
    }
    LPI(i,m)
    {
        s[B[i+1].l]+=s1[i+1]*B[i+1].d;
        s[B[i+1].r+1]-=s1[i+1]*B[i+1].d;
        s1[i+2]+=s1[i+1];
    }
    LPI(i,n)
    {

        cout<<(A[i+1]+s[i+1])<<" ";
        s[i+2]=s[i+2]+s[i+1];

    }

    return 0;
}


//DER.......
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<functional>
#include<math.h>
#include<assert.h>
#include<stdarg.h>
#include<time.h>
#include<limits.h>
#include<ctype.h>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<iostream>
#include<sstream>
using namespace std;

// #defines
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define LPI(i,n) for(int i=0;i<(n);i++)
#define LPI1(i,a,b) for(int i=(a);i<=(b);i++)
#define LPIL(i,x) for(int i=0;x[i];i++)
#define LPD(i,n) for(int i=(n)-1;i>=0;i--)
#define LPD1(i,a,b) for(int i=(a);i>=(b);i--)
#define I(x) scanf("%d",&x)
#define RI(x) int x;I(x)
#define II(x,y) scanf("%d%d",&x,&y)
#define RII(x,y) int x,y;II(x,y)
#define III(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define RIII(x,y,z) int x,y,z;III(x,y,z)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define CASET int ___T,cas=1;scanf("%d ",&___T);while(___T--)
#define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
#define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define F first
#define S second
#ifdef ONLINE_JUDGE
#define FILEIO(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define FILEIOS freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define FILEIO(x) ;
#define FILEIOS ;
#endif
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
LL A[100005];
int B[100005][4];
int s[100005];
int main(){
    RIII(n,m,k);
    LPI(i,n)
    {
        RI(x);
        A[i+1]=x;
    }
    LPI(i,m)
    {
        RIII(l,r,d);
        B[i+1][0]=l;B[i+1][1]=r;B[i+1][2]=d;
    }
    MS0(s);
    LPI(i,k)
    {
        RII(x,y);
        LPI1(j,x,y)
        {
            s[B[j][0]]+=B[j][2];
            s[B[j][1]+1]-=B[j][2];
        }
    }
    LPI(i,n)
    {

        cout<<(A[i+1]+s[i+1])<<" ";
        s[i+2]=s[i+2]+s[i+1];
    }

    return 0;
}


//DER.......
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<functional>
#include<math.h>
#include<assert.h>
#include<stdarg.h>
#include<time.h>
#include<limits.h>
#include<ctype.h>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<iostream>
#include<sstream>
using namespace std;

// #defines
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define LPI(i,n) for(int i=0;i<(n);i++)
#define LPI1(i,a,b) for(int i=(a);i<=(b);i++)
#define LPIL(i,x) for(int i=0;x[i];i++)
#define LPD(i,n) for(int i=(n)-1;i>=0;i--)
#define LPD1(i,a,b) for(int i=(a);i>=(b);i--)
#define I(x) scanf("%d",&x)
#define RI(x) int x;I(x)
#define II(x,y) scanf("%d%d",&x,&y)
#define RII(x,y) int x,y;II(x,y)
#define III(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define RIII(x,y,z) int x,y,z;III(x,y,z)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define CASET int ___T,cas=1;scanf("%d ",&___T);while(___T--)
#define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
#define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define F first
#define S second
#ifdef ONLINE_JUDGE
#define FILEIO(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define FILEIOS freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define FILEIO(x) ;
#define FILEIOS ;
#endif
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
LL A[100005];
int B[100005][4];
LL s[100005];
LL s1[10005];
int main(){
    int a,b,c;
    RIII(n,m,k);
    LPI(i,n)
    {
        RI(x);
        A[i+1]=x;
    }
    MS0(s);
    LPI(i,m)
    {
        RIII(l,r,d);
        B[i+1][0]=l;B[i+1][1]=r;B[i+1][2]=d;
    }
    MS0(s1);
    LPI(i,k)
    {
        RII(x,y);
        s1[x]+=1;
        s1[y+1]-=1;
    }
    LPI(i,m)
    {
        a=B[i+1][0];b=B[i+1][1];c=B[i+1][2];
        s[a]=s[a]+s1[i+1]*c;
        s[b+1]=s[b+1]-s1[i+1]*c;
        s1[i+2]=s1[i+2]+s1[i+1];
    }
    LPI(i,n)
    {

        cout<<(A[i+1]+s[i+1])<<" ";
        s[i+2]=s[i+2]+s[i+1];

    }

    return 0;
}