//ios::sync_with_stdio(false);
#include<bits/stdc++.h>
#define LL long long
#define F(x,y,z) for(int x=y;x<=z;++x)
#define D(x,y,z) for(int x=y;x>=z;--x)
#define ckmax(a,b) (a)=max(a,b)
#define ckmin(a,b) (a)=min(a,b)
#define pb push_back
#define pa pair<int,int>
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int N=100010;
LL R(){
    LL ans=0,f=1;char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if (c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) ans=ans*10+c-'0';
    return ans*f;
}
int K,n,m;
struct FS{
	LL x,y;int p,id;
	bool friend operator < (FS A,FS B){return A.x*B.y<A.y*B.x;}
};
priority_queue<FS> d;
vector<pa> v[N];
LL a[N],mx[N],pp[N];
vector<int> aq[3];
int oo[N];
void Work(int p){
	a[p]+=v[p].back().fi;
	v[p].pop_back();
	if(v[p].empty())return;
	if(v[p].back().fi>0)
		d.push((FS){v[p].back().fi,a[p],p,v[p].back().se});
}
int main(){
	//freopen("1.in","r",stdin);freopen("1.out","w",stdout);
	K=R();n=R();m=R();
	F(i,1,K)a[i]=R();
	F(i,1,n){
		int op=R();LL a=R(),b=R();
		oo[i]=op-1;
		if(op==1){
			if(b>=mx[a]){
				mx[a]=b;
				pp[a]=i;
			}
		}
		if(op==2)v[a].pb(mp(b,i));
		if(op==3)d.push((FS){b,1,0,i});
	}
	F(i,1,K){
		v[i].pb(mp(mx[i]-a[i],pp[i]));
		sort(v[i].begin(),v[i].end());
		if(v[i].back().fi>0)
			d.push((FS){v[i].back().fi,a[i],i,v[i].back().se});
	}
	int cc=0;
	while((!d.empty())&&cc+1<=m){
		int p=d.top().p;
		++cc;
		if(p==0){
			aq[oo[d.top().id]].pb(d.top().id);

		}
		else{
			aq[oo[d.top().id]].pb(d.top().id);
			Work(p);
		}
		d.pop();
	}
	cout<<cc;
	cout<<'\n';
	for(auto i:aq[0])cout<<i<<' ';
	for(auto i:aq[1])cout<<i<<' ';
	for(auto i:aq[2])cout<<i<<' ';
    return 0;
}


#include<bits/stdc++.h>
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
using namespace std;
const int maxn=1e5+9;
int a[maxn],k,n,m;
pair<int,int>as[maxn];
vector<pair<int,int> >add[maxn];
vector<pair<long double,int> >mul;
int stac[maxn],top,op[maxn];
bool cmp(int x,int y){
	return op[x]<op[y];
}
int main(){
	cin>>k>>n>>m;
	for(int i=1;i<=k;++i)cin>>a[i];
	for(int i=1;i<=n;++i){
		int opt,x,y;cin>>opt>>x>>y;
		op[i]=opt;
		if(opt==1){
			if(y>as[x].first)as[x].first=y,as[x].second=i;
		}
		if(opt==2){
			add[x].pb(mp(y,i));
		}
		if(opt==3){
			mul.pb(mp(y,i));
		}
	}
	for(int i=1;i<=k;++i){
		if(as[i].second&&as[i].first>a[i]){
			pair<int,int>now;
			now.first=as[i].first-a[i],now.second=as[i].second;
			add[i].pb(now);
		}
	}
	for(int i=1;i<=k;++i){
        sort(add[i].begin(),add[i].end(),greater<pair<int, int>>());
        long long v=a[i];
        for(auto p:add[i]){
            mul.pb(mp(1.0L*(v+p.first)/v,p.second));
            v+=p.first;
        }
    }
    sort(mul.begin(),mul.end(),greater<pair<long double,int> >());
    int t=min((int)mul.size(),m);
    for(auto x:mul){
		if(top==t)break;
    	stac[++top]=x.second;
    }
    sort(stac+1,stac+1+top,cmp);
    cout<<t<<endl;
    for(int i=1;i<=top;++i)cout<<stac[i]<<" ";
}


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

#define ll long long
#define pb push_back
#define ld long double

const int maxn = 1e5 + 20;

vector<int> Add[maxn];

int a[maxn] , mx[maxn] , pt[maxn];
int type[maxn] , p[maxn] , b[maxn];

bool cmp1(int x , int y)
{
	return b[x] > b[y];
}

bool cmp2(int x , int y)
{
	return type[x] < type[y];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int k , n , m;
	cin >> k >> n >> m;

	for(int i = 0; i < k; i++)
		cin >> a[i];

	vector<pair<ld , int> > Mul;
	for(int i = 0; i < n; i++)
	{
		cin >> type[i] >> p[i] >> b[i];
		p[i]--;

		if(type[i] == 1 && mx[p[i]] < b[i])
			mx[p[i]] = b[i] , pt[p[i]] = i;

		if(type[i] == 2)
			Add[p[i]].pb(i);

		if(type[i] == 3)
			Mul.pb({b[i] , i});
	}

	for(int i = 0; i < k; i++)
	{
		if(mx[i] > a[i])
		{
			b[pt[i]] -= a[i];
			Add[i].pb(pt[i]);
		}

		sort(Add[i].begin() , Add[i].end() , cmp1);

		for(auto x : Add[i])
		{
			ld y = (ld)(a[i] + b[x]) / (ld)(a[i]);
			Mul.pb({y , x});

			a[i] += b[x];
		}
	}

	sort(Mul.begin() , Mul.end());
	reverse(Mul.begin() , Mul.end());

	vector<int> ans;
	if(m)
		for(auto x : Mul)
		{
			ans.pb(x.second);

			if((int)ans.size() == m)
				break;
		}

	sort(ans.begin() , ans.end() , cmp2);
	cout << ans.size() << endl;
	for(auto x : ans)
		cout << x + 1 << " ";
	cout << endl;

}


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

#define ll long long
#define pb push_back
#define ld long double
#define int ll

const int maxn = 1e5 + 20;

vector<int> Add[maxn];

int a[maxn] , mx[maxn] , pt[maxn];
int type[maxn] , p[maxn] , b[maxn];

bool cmp1(int x , int y)
{
	return b[x] > b[y];
}

bool cmp2(int x , int y)
{
	return type[x] < type[y];
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int k , n , m;
	cin >> k >> n >> m;

	for(int i = 0; i < k; i++)
		cin >> a[i];

	vector<pair<ld , int> > Mul;
	for(int i = 0; i < n; i++)
	{
		cin >> type[i] >> p[i] >> b[i];
		p[i]--;

		if(type[i] == 1 && mx[p[i]] < b[i])
			mx[p[i]] = b[i] , pt[p[i]] = i;

		if(type[i] == 2)
			Add[p[i]].pb(i);

		if(type[i] == 3)
			Mul.pb({b[i] , i});
	}

	for(int i = 0; i < k; i++)
	{
		if(mx[i] > a[i])
		{
			b[pt[i]] -= a[i];
			Add[i].pb(pt[i]);
		}

		sort(Add[i].begin() , Add[i].end() , cmp1);

		for(auto x : Add[i])
		{
			ld y = (ld)(a[i] + b[x]) / (ld)(a[i]);
			Mul.pb({y , x});

			a[i] += b[x];
		}
	}

	sort(Mul.begin() , Mul.end());
	reverse(Mul.begin() , Mul.end());

	vector<int> ans;
	if(m)
		for(auto x : Mul)
		{
			ans.pb(x.second);

			if((int)ans.size() == m)
				break;
		}

	sort(ans.begin() , ans.end() , cmp2);
	cout << ans.size() << endl;
	for(auto x : ans)
		cout << x + 1 << " ";
	cout << endl;

}


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

#define ll long long
#define pb push_back
#define ld long double

const int maxn = 1e5 + 20;

vector<int> Add[maxn];

int a[maxn] , mx[maxn] , pt[maxn];
int type[maxn] , p[maxn] , b[maxn];

bool cmp1(int x , int y)
{
	return b[x] > b[y];
}

bool cmp2(int x , int y)
{
	return type[x] < type[y];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int k , n , m;
	cin >> k >> n >> m;

	for(int i = 0; i < k; i++)
		cin >> a[i];

	vector<pair<ld , int> > Mul;
	for(int i = 0; i < n; i++)
	{
		cin >> type[i] >> p[i] >> b[i];
		p[i]--;

		if(type[i] == 1 && mx[p[i]] < b[i])
			mx[p[i]] = b[i] , pt[p[i]] = i;

		if(type[i] == 2)
			Add[p[i]].pb(i);

		if(type[i] == 3)
			Mul.pb({b[i] , i});
	}

	for(int i = 0; i < k; i++)
	{
		if(mx[i] > a[i])
		{
			b[pt[i]] -= a[i];
			Add[i].pb(pt[i]);
		}

		sort(Add[i].begin() , Add[i].end() , cmp1);

		for(auto x : Add[i])
		{
			ld y = (ld)(a[i] + b[x]) / (ld)(a[i]);
			Mul.pb({y , x});

			a[i] += b[x];
		}
	}

	sort(Mul.begin() , Mul.end());
	reverse(Mul.begin() , Mul.end());

	vector<int> ans;
	for(auto x : Mul)
	{
		ans.pb(x.second);

		if((int)ans.size() == m)
			break;
	}

	sort(ans.begin() , ans.end() , cmp2);
	cout << ans.size() << endl;
	for(auto x : ans)
		cout << x + 1 << " ";
	cout << endl;

}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define max(x,y) x > y ? x : y
#define min(x,y) x < y ? x : y

int tot, k, n, m, x[100005], val[100005];
struct operationA {
	long double val;
	int pos, id, type;
}a[100005];
struct operationB {
	int pos, type, val, id;
}b[100005];

inline bool cmp1(operationB x, operationB y) {
	if (x.type == y.type) {
		if (x.pos == y.pos)
			return x.val > y.val;
		else return x.pos < y.pos;
	} else return x.type < y.type;
}
inline bool cmp2(operationA x, operationA y) { return x.val > y.val; }
inline bool cmp3(operationA x, operationA y) { return x.type < y.type; }

int main() {
	scanf("%d%d%d", &k, &n, &m);
	for (int i = 1; i <= k; ++i)
		scanf("%d", val + i);
	for (int i = 1; i <= n; ++i)
		scanf("%d%d%d", &b[i].type, &b[i].pos, &b[i].val), b[i].id = i;
	std::sort (b + 1, b + n + 1, cmp1);
	register int i = 1, j;
	for ( ; b[i].type == 1; ++i) {
		if (b[i].pos == b[i - 1].pos) continue;
		else {
			if (b[i].val < val[i]) continue;
			a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
			a[tot].val = b[i].val - val[i], a[tot].type = 1;
		}
	}
	for (i = b[i].type >= 2 ? i : i + 1; b[i].type == 2; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val - val[i], a[tot].type = 2;
	}
	std::sort (a + 1, a + tot + 1, cmp2);
	for (j = 1; j <= tot; ++j) {
		val[a[j].pos] += a[j]. val;
		a[j].val = (long double) val[a[j].pos] / (val[a[j].pos] - a[j].val);
	}
	for (i = b[i].type == 3 ? i : i + 1; b[i].type == 3; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val, a[tot].type = 3;
	}
	std::sort (a + 1, a + tot + 1, cmp2), m = min(tot, m);
	std::sort (a + 1, a + m + 1, cmp3), printf("%d\n", m);
	for (int i = 1; i < m; ++i) printf("%d ", a[i].id);
	if (m) printf("%d\n", a[m].id);
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define max(x,y) x > y ? x : y
#define min(x,y) x < y ? x : y

long long tot, k, n, m, x[100005], val[100005];
struct operationA {
	long double val;
	long long pos, id, type;
}a[100005];
struct operationB {
	long long pos, type, val, id;
}b[100005];

inline bool cmp1(operationB x, operationB y) {
	if (x.type == y.type) {
		if (x.pos == y.pos)
			return x.val > y.val;
		else return x.pos < y.pos;
	} else return x.type < y.type;
}
inline bool cmp2(operationA x, operationA y) { return x.val > y.val; }
inline bool cmp3(operationA x, operationA y) { return x.type < y.type; }

int main() {
	scanf("%lld%lld%lld", &k, &n, &m);
	for (int i = 1; i <= k; ++i)
		scanf("%lld", val + i);
	for (int i = 1; i <= n; ++i)
		scanf("%lld%lld%lld", &b[i].type, &b[i].pos, &b[i].val), b[i].id = i;
	std::sort (b + 1, b + n + 1, cmp1);
	register int i = 1, j;
	for ( ; b[i].type == 1; ++i) {
		if (b[i].pos == b[i - 1].pos) continue;
		else {
			if (b[i].val < val[i]) continue;
			a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
			a[tot].val = b[i].val - val[i], a[tot].type = 1;
		}
	}
	for ( ; b[i].type == 2; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val, a[tot].type = 2;
	}
	std::sort (a + 1, a + tot + 1, cmp2);
	for (j = 1; j <= tot; ++j) {
		val[a[j].pos] += a[j]. val;
		a[j].val = (long double) val[a[j].pos] / (val[a[j].pos] - a[j].val);
	}
	for ( ; b[i].type == 3; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val, a[tot].type = 3;
	}
	std::sort (a + 1, a + tot + 1, cmp2), m = min(tot, m);
	std::sort (a + 1, a + m + 1, cmp3), printf("%lld\n", m);
	for (int i = 1; i < m; ++i) printf("%lld ", a[i].id);
	if (m) printf("%lld\n", a[m].id);
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define max(x,y) x > y ? x : y
#define min(x,y) x < y ? x : y

long long tot, k, n, m, x[100005], val[100005];
struct operationA {
	long double val;
	long long pos, id, type;
}a[100005];
struct operationB {
	long long pos, type, val, id;
}b[100005];

inline bool cmp1(operationB x, operationB y) {
	if (x.type == y.type) {
		if (x.pos == y.pos)
			return x.val > y.val;
		else return x.pos < y.pos;
	} else return x.type < y.type;
}
inline bool cmp2(operationA x, operationA y) { return x.val > y.val; }
inline bool cmp3(operationA x, operationA y) { return x.type < y.type; }

int main() {
	scanf("%lld%lld%lld", &k, &n, &m);
	for (int i = 1; i <= k; ++i)
		scanf("%lld", val + i);
	for (int i = 1; i <= n; ++i)
		scanf("%lld%lld%lld", &b[i].type, &b[i].pos, &b[i].val), b[i].id = i;
	std::sort (b + 1, b + n + 1, cmp1);
	register int i = 1, j;
	for ( ; b[i].type == 1; ++i) {
		if (b[i].pos == b[i - 1].pos) continue;
		else {
			if (b[i].val < val[b[i].pos]) continue;
			a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
			a[tot].val = b[i].val - val[b[i].pos], a[tot].type = 1;
		}
	}
	for ( ; b[i].type == 2; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val, a[tot].type = 2;
	}
	std::sort (a + 1, a + tot + 1, cmp2);
	for (j = 1; j <= tot; ++j) {
		val[a[j].pos] += a[j]. val;
		a[j].val = (long double) val[a[j].pos] / (val[a[j].pos] - a[j].val);
	}
	for ( ; b[i].type == 3; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val, a[tot].type = 3;
	}
	std::sort (a + 1, a + tot + 1, cmp2), m = min(tot, m);
	std::sort (a + 1, a + m + 1, cmp3), printf("%lld\n", m);
	for (int i = 1; i < m; ++i) printf("%lld ", a[i].id);
	if (m) printf("%lld\n", a[m].id);
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define max(x,y) x > y ? x : y
#define min(x,y) x < y ? x : y

int tot, k, n, m, x[100005], val[100005];
struct operationA {
	long double val;
	int pos, id;
}a[100005];
struct operationB {
	int pos, type, val, id;
}b[100005];

inline bool cmp1(operationB x, operationB y) {
	if (x.type == y.type) {
		if (x.pos == y.pos)
			return x.val > y.val;
		else return x.pos < y.pos;
	} else return x.type < y.type;
}
inline bool cmp2(operationA x, operationA y) { return x.val > y.val; }
inline bool cmp3(operationA x, operationA y) { return x.id < y.id; }

int main() {
	scanf("%d%d%d", &k, &n, &m);
	for (int i = 1; i <= k; ++i)
		scanf("%d", val + i);
	for (int i = 1; i <= n; ++i)
		scanf("%d%d%d", &b[i].type, &b[i].pos, &b[i].val), b[i].id = i;
	std::sort (b + 1, b + n + 1, cmp1);
	register int i = 1, j;
	for ( ; b[i].type == 1; ++i) {
		if (b[i].pos == b[i - 1].pos) continue;
		else {
			if (b[i].val < val[i]) continue;
			a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
			a[tot].val = b[i].val - val[i];
		}
	}
	for (i = b[i].type == 2 ? i : i + 1; b[i].type == 2; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val - val[i];
	}
	std::sort (a + 1, a + tot + 1, cmp2);
	for (j = 1; j <= tot; ++j) {
		val[a[j].pos] += a[j]. val;
		a[j].val = (long double) val[a[j].pos] / (val[a[j].pos] - a[j].val);
	}
	for (i = b[i].type == 3 ? i : i + 1; b[i].type == 3; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val;
	}
	std::sort (a + 1, a + tot + 1, cmp2), m = min(tot, m);
	std::sort (a + 1, a + m + 1, cmp3), printf("%d\n", m);
	for (int i = 1; i < m; ++i) printf("%d ", a[i].id);
	printf("%d\n", a[m].id);
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define max(x,y) x > y ? x : y
#define min(x,y) x < y ? x : y

int tot, k, n, m, x[100005], val[100005];
struct operationA {
	long double val;
	int pos, id;
}a[100005];
struct operationB {
	int pos, type, val, id;
}b[100005];

inline bool cmp1(operationB x, operationB y) {
	if (x.type == y.type) {
		if (x.pos == y.pos)
			return x.val > y.val;
		else return x.pos < y.pos;
	} else return x.type < y.type;
}
inline bool cmp2(operationA x, operationA y) { return x.val > y.val; }
inline bool cmp3(operationA x, operationA y) { return x.id < y.id; }

int main() {
	scanf("%d%d%d", &k, &n, &m);
	for (int i = 1; i <= k; ++i)
		scanf("%d", val + i);
	for (int i = 1; i <= n; ++i)
		scanf("%d%d%d", &b[i].type, &b[i].pos, &b[i].val), b[i].id = i;
	std::sort (b + 1, b + n + 1, cmp1);
	register int i = 1, j;
	for ( ; b[i].type == 1; ++i) {
		if (b[i].pos == b[i - 1].pos) continue;
		else {
			if (b[i].val < val[i]) continue;
			a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
			a[tot].val = b[i].val - val[i];
		}
	}
	for (i = b[i].type >= 2 ? i : i + 1; b[i].type == 2; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val - val[i];
	}
	std::sort (a + 1, a + tot + 1, cmp2);
	for (j = 1; j <= tot; ++j) {
		val[a[j].pos] += a[j]. val;
		a[j].val = (long double) val[a[j].pos] / (val[a[j].pos] - a[j].val);
	}
	for (i = b[i].type == 3 ? i : i + 1; b[i].type == 3; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val;
	}
	std::sort (a + 1, a + tot + 1, cmp2), m = min(tot, m);
	std::sort (a + 1, a + m + 1, cmp3), printf("%d\n", m);
	for (int i = 1; i < m; ++i) printf("%d ", a[i].id);
	if (m) printf("%d\n", a[m].id);
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define max(x,y) x > y ? x : y
#define min(x,y) x < y ? x : y

int tot, k, n, m, x[100005], val[100005];
struct operationA {
	long double val;
	int pos, id;
}a[100005];
struct operationB {
	int pos, type, val, id;
}b[100005];

inline bool cmp1(operationB x, operationB y) {
	if (x.type == y.type) {
		if (x.pos == y.pos)
			return x.val > y.val;
		else return x.pos < y.pos;
	} else return x.type < y.type;
}
inline bool cmp2(operationA x, operationA y) { return x.val > y.val; }
inline bool cmp3(operationA x, operationA y) { return x.id < y.id; }

int main() {
	scanf("%d%d%d", &k, &n, &m);
	for (int i = 1; i <= k; ++i)
		scanf("%d", val + i);
	for (int i = 1; i <= n; ++i)
		scanf("%d%d%d", &b[i].type, &b[i].pos, &b[i].val), b[i].id = i;
	std::sort (b + 1, b + n + 1, cmp1);
	register int i = 1, j;
	for ( ; b[i].type == 1; ++i) {
		if (b[i].pos == b[i - 1].pos) continue;
		else {
			if (b[i].val < val[i]) continue;
			a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
			a[tot].val = b[i].val - val[i];
		}
	}
	for (i = b[i].type == 2 ? i : i + 1; b[i].type == 2; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val - val[i];
	}
	std::sort (a + 1, a + tot + 1, cmp2);
	for (j = 1; j <= tot; ++j) {
		val[a[j].pos] += a[j]. val;
		a[j].val = (long double) val[a[j].pos] / (val[a[j].pos] - a[j].val);
	}
	for (i = b[i].type == 3 ? i : i + 1; b[i].type == 3; ++i) {
		a[++tot].pos = b[i].pos, a[tot].id = b[i].id;
		a[tot].val = b[i].val;
	}
	std::sort (a + 1, a + tot + 1, cmp2), m = min(tot, m);
	std::sort (a + 1, a + m + 1, cmp3), printf("%d\n", m);
	for (int i = 1; i < m; ++i) printf("%d ", a[i].id);
	if (m) printf("%d\n", a[m].id);
	return 0;
}


#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;

static char stdinBuffer[1024];
static char* stdinDataEnd = stdinBuffer + sizeof (stdinBuffer);
static const char* stdinPos = stdinDataEnd;

void readAhead(size_t amount)
{
    size_t remaining = stdinDataEnd - stdinPos;
    if (remaining < amount) {
       memmove(stdinBuffer, stdinPos, remaining);
       size_t sz = fread(stdinBuffer + remaining, 1, sizeof (stdinBuffer) - remaining, stdin);
       stdinPos = stdinBuffer;
       stdinDataEnd = stdinBuffer + remaining + sz;
       if (stdinDataEnd != stdinBuffer + sizeof (stdinBuffer))
         *stdinDataEnd = 0;
    }
}

int readInt()
{
    readAhead(16);

    int x = 0;
    bool neg = false;
    while(*stdinPos==' '||*stdinPos=='\n') ++stdinPos;
    if (*stdinPos == '-') {
       ++stdinPos;
       neg = true;
    }

    while (*stdinPos >= '0' && *stdinPos <= '9') {
       x *= 10;
       x += *stdinPos - '0';
       ++stdinPos;
    }

    return neg ? -x : x;
}

const int maxn=1e5+2;
typedef pair<int,int> pii;
pii bestassign[maxn];
vector<pii> vadd[maxn];
vector<pii> vmul;
ll a[maxn];
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  int k=readInt(),n=readInt(),m=readInt();
  for (int i=0;i<k;i++) {
    a[i]=readInt();
  }
  for (int i=1;i<=n;i++) {
    int t=readInt();
    int skill=readInt()-1;
    int b=readInt();
    if (t==1) {
      chkmax(bestassign[skill], MP(b,-i));
    }
    else if (t==2) vadd[skill].PB(MP(b,i));
    else {
      if (b>1) vmul.PB(MP(b,i));
    }
  }
  for (int skill=0;skill<k;skill++) {
    int gain=bestassign[skill].fst - a[skill];
    if (gain>0) {
      vadd[skill].PB(MP(gain, bestassign[skill].snd));
    }
  }
  sort(vmul.begin(),vmul.end(),greater<pii>());
  vector<pair<ld, int> > valladd;
  for (int skill=0;skill<k;skill++) {
    sort(vadd[skill].begin(),vadd[skill].end(),greater<pii>());
    int sz=vadd[skill].size();
    for (auto &w: vadd[skill]) {
      int add=w.fst,id=w.snd;
      ll numer=a[skill]+add;
      ll denom=a[skill];
      ld frac=((ld)denom)/((ld)numer);
      valladd.PB(MP(frac,id));
      a[skill]+=add;
    }
  }
  sort(valladd.begin(),valladd.end());
  int finaladdsteps=min(m,(int)(valladd.size()));
  {
    int addsteps=finaladdsteps;
    int prevmulsteps=min((int)(vmul.size()), m-addsteps);
    --addsteps;
    for (;addsteps>=0;addsteps--) {
      int mulsteps=min((int)(vmul.size()), m-addsteps);
      ld frac=valladd[addsteps].fst;
      //printf("va:%f\n",(double)valladd[addsteps].fst);
      if (mulsteps!=prevmulsteps) {
        frac=frac*vmul[mulsteps-1].fst;
        //printf("vm:%d\n",vmul[mulsteps-1].fst);
      }
      //printf("addsteps:%d mulsteps:%d frac:%f\n",addsteps,mulsteps,(double)frac);
      if (frac>=1) {
        finaladdsteps=addsteps;
      }
      prevmulsteps=mulsteps;
    }
  }
  {
    int addsteps=finaladdsteps;
    int mulsteps=min((int)(vmul.size()), m-addsteps);
    //printf("%d %d\n",addsteps,mulsteps);
    printf("%d\n",addsteps+mulsteps);
    vector<int> finalorder;
    for (int i=0;i<addsteps;i++) {
      finalorder.PB(valladd[i].snd);
    }
    sort(finalorder.begin(),finalorder.end());
    for (auto &w:finalorder) {
      printf("%d ",abs(w));
    }
    for (int i=0;i<mulsteps;i++) {
      printf("%d ",vmul[i].snd);
    }
    printf("\n");
  }
}


/*program by mangoyang*/
#pragma GCC optimize("Ofast", "inline")
#include<bits/stdc++.h>
#define inf (0x3f3f3f3f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
    int ch = 0, f = 0; x = 0;
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if(f) x = -x;
}
const int N = 114514;
vector<pair<int, int> > g[N];
struct Node{
	ll x, y; int id;
} A[N];
int a[N], mx[N], id[N], n, m, k, cnt;
inline bool cmp(Node &A, Node &B){
	ll ax = A.x - A.y, bx = B.x - B.y;
	return ax * B.y > bx * A.y;
}
int main(){
	read(k), read(n), read(m);
	for(int i = 1; i <= k; i++) read(a[i]);
	for(int i = 1, x, y, z; i <= n; i++){
		read(x), read(y), read(z);
		if(x == 1)
			if(z > mx[y]) mx[y] = z, id[y] = i;
		if(x == 2) g[y].push_back(make_pair(z, i));
		if(x == 3) A[++cnt] = (Node){z, 1, i};
	}
	for(int i = 1; i <= k; i++){
		if(mx[i] > a[i] && id[i])
			g[i].push_back(make_pair(mx[i] - a[i], id[i]));
		sort(g[i].begin(), g[i].end());
		ll sum = a[i];
		for(int j = 0; j < (int) g[i].size(); j++){
			A[++cnt] = (Node){sum + g[i][j].first, sum, g[i][j].second};
			sum += g[i][j].first;
		}
	}
	sort(A + 1, A + cnt + 1, cmp);
	printf("%d\n", min(cnt, m));
	for(int i = 1; i <= min(cnt, m); i++)
		printf("%d ", A[i].id);
	return 0;
}


/*program by mangoyang*/
#pragma GCC optimize("Ofast", "inline")
#include<bits/stdc++.h>
#define inf (0x3f3f3f3f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
    int ch = 0, f = 0; x = 0;
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if(f) x = -x;
}
const int N = 114514;
vector<pair<int, int> > g[N];
struct Node{
	ll x, y; int id, type;
} A[N];
int a[N], mx[N], id[N], n, m, k, cnt;
inline bool cmp(Node &A, Node &B){
	ll ax = A.x - A.y, bx = B.x - B.y;
	return ax * B.y > bx * A.y;
}
inline bool cmp2(Node &A, Node &B){
	return A.type < B.type;
}
int main(){
	read(k), read(n), read(m);
	for(int i = 1; i <= k; i++) read(a[i]);
	for(int i = 1, x, y, z; i <= n; i++){
		read(x), read(y), read(z);
		if(x == 1)
			if(z > mx[y]) mx[y] = z, id[y] = i;
		if(x == 2) g[y].push_back(make_pair(z, i));
		if(x == 3) A[++cnt] = (Node){z, 1, i, 2};
	}
	for(int i = 1; i <= k; i++){
		int spid = 0;
		if(mx[i] > a[i] && id[i])
			g[i].push_back(make_pair(mx[i] - a[i], id[i])), spid = id[i];
		sort(g[i].begin(), g[i].end());
		ll sum = a[i];
		for(int j = 0; j < (int) g[i].size(); j++){
			A[++cnt] = (Node){sum + g[i][j].first, sum, g[i][j].second, g[i][j].second != spid};
			sum += g[i][j].first;
		}
	}
	sort(A + 1, A + cnt + 1, cmp);
	sort(A + 1, A + min(m, cnt) + 1, cmp2);
	printf("%d\n", min(cnt, m));
	for(int i = 1; i <= min(cnt, m); i++)
		printf("%d ", A[i].id);
	return 0;
}


/*program by mangoyang*/
#pragma GCC optimize("Ofast", "inline")
#include<bits/stdc++.h>
#define inf (0x3f3f3f3f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
    int ch = 0, f = 0; x = 0;
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if(f) x = -x;
}
const int N = 114514;
vector<pair<int, int> > g[N];
struct Node{
	ll x, y; int id, type;
} A[N];
int a[N], mx[N], id[N], n, m, k, cnt;
inline bool cmp(Node &A, Node &B){
	ll ax = A.x - A.y, bx = B.x - B.y;
	return ax * B.y > bx * A.y;
}
inline bool cmp2(Node &A, Node &B){
	return A.type < B.type;
}
inline bool cmp3(pair<int, int> A, pair<int, int> B){
	return A.first > B.first;
}
int main(){
	read(k), read(n), read(m);
	for(int i = 1; i <= k; i++) read(a[i]);
	for(int i = 1, x, y, z; i <= n; i++){
		read(x), read(y), read(z);
		if(x == 1)
			if(z > mx[y]) mx[y] = z, id[y] = i;
		if(x == 2) g[y].push_back(make_pair(z, i));
		if(x == 3) A[++cnt] = (Node){z, 1, i, 2};
	}
	for(int i = 1; i <= k; i++){
		int spid = 0;
		if(mx[i] > a[i] && id[i])
			g[i].push_back(make_pair(mx[i] - a[i], id[i])), spid = id[i];
		sort(g[i].begin(), g[i].end(), cmp3);
		ll sum = a[i];
		for(int j = 0; j < (int) g[i].size(); j++){
			A[++cnt] = (Node){sum + g[i][j].first, sum, g[i][j].second, g[i][j].second != spid};
			sum += g[i][j].first;
		}
	}
	sort(A + 1, A + cnt + 1, cmp);
	sort(A + 1, A + min(m, cnt) + 1, cmp2);
	printf("%d\n", min(cnt, m));
	for(int i = 1; i <= min(cnt, m); i++)
		printf("%d ", A[i].id);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Maxn=100005;
int a[Maxn],cov[Maxn];
vector<int>add[Maxn];
struct node{
    int t,pos,val,id;
    double _val;
}w[Maxn];
int main(){
    int k,n,m;scanf("%d%d%d",&k,&n,&m);
    for(int i=1;i<=k;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",&w[i].t,&w[i].pos,&w[i].val),w[i].id=i;
        if(w[i].t==1&&w[i].val>w[cov[w[i].pos]].val)
            cov[w[i].pos]=i;
        if(w[i].t==2)add[w[i].pos].push_back(i);
    }
    for(int i=1;i<=n;i++)
        if(w[i].t==3)w[i]._val=w[i].val;
    for(int i=1;i<=k;i++){
        if(cov[i])add[i].push_back(cov[i]);
        auto Val=[&](const node&b){
            if(b.t==2)return b.val;
            return b.val-a[i];
        };
        sort(add[i].begin(),add[i].end(),[&](int a,int b){
            return Val(w[a])>Val(w[b]);
        });
        ll lst=a[i];
        for(auto j:add[i]){
            if(Val(w[j])<=0)continue;
            w[j]._val=1.0*(lst+Val(w[j]))/lst;
            lst+=Val(w[j]);
        }
    }
    // for(int i=1;i<=n;i++){
    //     cout<<"t="<<w[i].t<<" pos="<<w[i].pos<<" val="<<w[i].val<<" _val="<<w[i]._val<<"\n";
    // }
    sort(w+1,w+n+1,[](const node&a,const node&b){
        return a._val>b._val;
    });
    // for(int i=1;i<=n;i++){
    //     cout<<"t="<<w[i].t<<" pos="<<w[i].pos<<" val="<<w[i].val<<" _val="<<w[i]._val<<" id="<<w[i].id<<"\n";
    // }
    while(m>=1&&w[m]._val<1)m--;
    sort(w+1,w+m+1,[](const node&a,const node&b){
        return a.t<b.t;
    });
    cout<<m<<"\n";
    for(int i=1;i<=m;i++)
        cout<<w[i].id<<" \n"[i==m];
    return 0;
}


//starusc
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return f==1?x:-x;
}
const int N=1e5+4;
int n,m,k,a[N],op[N],b[N],mx[N];
vector<pair<int,int> >ad[N];
vector<pair<double,int> >ml;
vector<int>ans;
inline bool comp(int x,int y){
	return op[x]<op[y];
}
signed main(){
	k=read();n=read();m=read();
	for(int i=1;i<=k;i++)a[i]=read();
	for(int i=1,u;i<=n;i++){
		op[i]=read();u=read();b[i]=read();
		if(op[i]==1){
			if(b[i]>b[mx[u]])mx[u]=i;
		}
		else if(op[i]==2){
			ad[u].push_back(make_pair(b[i],i));
		}
		else{
			ml.push_back(make_pair(b[i],i));
		}
	}
	for(int i=1;i<=k;i++){
		if(b[mx[i]]>a[i])ad[i].push_back(make_pair(b[mx[i]]-a[i],mx[i]));
		sort(ad[i].begin(),ad[i].end());
		for(int j=(signed)ad[i].size()-1,sum=a[i];j>=0;j--){
			ml.push_back(make_pair((double)(ad[i][j].first+sum)/sum,ad[i][j].second));
			sum+=ad[i][j].first;
		}
	}
	sort(ml.begin(),ml.end());
	for(int i=(signed)ml.size()-1;i>=0&&m--;i--)ans.push_back(ml[i].second);
	sort(ans.begin(),ans.end(),comp);
	cout<<ans.size()<<"\n";
	for(auto v:ans)cout<<v<<" ";
	return (0-0);
}


/*
    Author: zxy_hhhh
    date: 2020/01/17
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#define ll long long
inline ll rd() {
    ll _x=0;int _ch=getchar(),_f=1;
    for(;!isdigit(_ch)&&(_ch!='-')&&(_ch!=EOF);_ch=getchar());
    if (_ch=='-'){_f=0;_ch=getchar();}
    for(;isdigit(_ch);_ch=getchar()) _x=_x*10+_ch-'0';
    return _f?_x:-_x;
}
void write(ll _x){if (_x>=10) write(_x/10),putchar(_x%10+'0'); else putchar(_x+'0'); }
inline void wrt(ll _x,char _p){if (_x<0) putchar('-'),_x=-_x; write(_x); if (_p) putchar(_p);}
#define maxn 100005
int k,n,m;
int a[maxn],opt[maxn];
std::pair<int,int> mx[maxn];
std::vector< std::pair<int,int> > add[maxn];
std::priority_queue< std::pair<double,int> > que;
std::vector<int> result;
inline int cmp(int A,int B) {return opt[A]<opt[B];}
int main() {
    // freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    k=rd(),n=rd(),m=rd();
    for(int i=1;i<=k;i++) {
        a[i]=rd();
    }
    for(int i=1;i<=n;i++) {
        int op=rd(),pos=rd(),val=rd();
        opt[i]=op;
        if (op==1) {
            mx[pos]=std::max(mx[pos],std::make_pair(val,i));
        }
        else if (op==2) {
            add[pos].push_back(std::make_pair(val,i));
        }
        else {
            que.push(std::make_pair(val,i));
        }
    }
    for(int i=1;i<=k;i++) {
        add[i].push_back(std::make_pair(mx[i].first-a[i],mx[i].second));
    }
    for(int i=1;i<=k;i++) {
        ll sum=0;
        for(auto j:add[i]) {
            sum+=j.first;
            que.push(std::make_pair((a[i]+sum)/double(a[i]+sum-j.first),j.second));
        }
    }
    for(int i=1;i<=m&&que.top().first>1;i++) {
        result.push_back(que.top().second);
        que.pop();
    }
    std::sort(result.begin(),result.end(),cmp);
    wrt(result.size(),'\n');
    for(auto i:result)
        wrt(i,' ');
}


/*
    Author: zxy_hhhh
    date: 2020/01/17
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#define ll long long
inline ll rd() {
    ll _x=0;int _ch=getchar(),_f=1;
    for(;!isdigit(_ch)&&(_ch!='-')&&(_ch!=EOF);_ch=getchar());
    if (_ch=='-'){_f=0;_ch=getchar();}
    for(;isdigit(_ch);_ch=getchar()) _x=_x*10+_ch-'0';
    return _f?_x:-_x;
}
void write(ll _x){if (_x>=10) write(_x/10),putchar(_x%10+'0'); else putchar(_x+'0'); }
inline void wrt(ll _x,char _p){if (_x<0) putchar('-'),_x=-_x; write(_x); if (_p) putchar(_p);}
#define maxn 100005
int k,n,m;
int a[maxn],opt[maxn];
std::pair<int,int> mx[maxn];
std::vector< std::pair<int,int> > add[maxn];
std::priority_queue< std::pair<long double,int> > que;
std::vector<int> result;
inline int cmp(int A,int B) {return opt[A]<opt[B];}
int main() {
    // freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    k=rd(),n=rd(),m=rd();
    for(int i=1;i<=k;i++) {
        a[i]=rd();
    }
    for(int i=1;i<=n;i++) {
        int op=rd(),pos=rd(),val=rd();
        opt[i]=op;
        if (op==1) {
            mx[pos]=std::max(mx[pos],std::make_pair(val,i));
        }
        else if (op==2) {
            add[pos].push_back(std::make_pair(val,i));
        }
        else {
            que.push(std::make_pair(val,i));
        }
    }
    for(int i=1;i<=k;i++) {
        add[i].push_back(std::make_pair(mx[i].first-a[i],mx[i].second));
    }
    for(int i=1;i<=k;i++) {
        sort(add[i].begin(),add[i].end());
        ll sum=0;
        for(auto j:add[i]) {
            sum+=j.first;
            que.push(std::make_pair((a[i]+sum)/(long double)(a[i]+sum-j.first),j.second));
        }
    }
    for(int i=1;i<=m&&que.top().first>1;i++) {
        result.push_back(que.top().second);
        que.pop();
    }
    std::sort(result.begin(),result.end(),cmp);
    wrt(result.size(),'\n');
    for(auto i:result)
        wrt(i,' ');
}


/*
    Author: zxy_hhhh
    date: 2020/01/17
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<iostream>
#define ll long long
inline ll rd() {
    ll _x=0;int _ch=getchar(),_f=1;
    for(;!isdigit(_ch)&&(_ch!='-')&&(_ch!=EOF);_ch=getchar());
    if (_ch=='-'){_f=0;_ch=getchar();}
    for(;isdigit(_ch);_ch=getchar()) _x=_x*10+_ch-'0';
    return _f?_x:-_x;
}
void write(ll _x){if (_x>=10) write(_x/10),putchar(_x%10+'0'); else putchar(_x+'0'); }
inline void wrt(ll _x,char _p){if (_x<0) putchar('-'),_x=-_x; write(_x); if (_p) putchar(_p);}
#define maxn 100005
int k,n,m;
int a[maxn],opt[maxn];
std::pair<int,int> mx[maxn];
std::vector< std::pair<int,int> > add[maxn];
std::priority_queue< std::pair<long double,int> > que;
std::vector<int> result;
inline int cmp(int A,int B) {return opt[A]<opt[B];}
int main() {
    // freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    k=rd(),n=rd(),m=rd();
    for(int i=1;i<=k;i++) {
        a[i]=rd();
    }
    for(int i=1;i<=n;i++) {
        int op=rd(),pos=rd(),val=rd();
        opt[i]=op;
        if (op==1) {
            mx[pos]=std::max(mx[pos],std::make_pair(val,i));
        }
        else if (op==2) {
            add[pos].push_back(std::make_pair(val,i));
        }
        else {
            que.push(std::make_pair(val,i));
        }
    }
    for(int i=1;i<=k;i++) {
        add[i].push_back(std::make_pair(mx[i].first-a[i],mx[i].second));
    }
    for(int i=1;i<=k;i++) {
        sort(add[i].begin(),add[i].end(),std::greater< std::pair<int,int> >());
        ll sum=0;
        for(auto j:add[i]) {
            sum+=j.first;
            que.push(std::make_pair((a[i]+sum)/(long double)(a[i]+sum-j.first),j.second));
        }
    }
    for(int i=1;i<=m&&que.top().first>1;i++) {
        result.push_back(que.top().second);
        que.pop();
    }
    std::sort(result.begin(),result.end(),cmp);
    wrt(result.size(),'\n');
    for(auto i:result)
        wrt(i,' ');
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 100005;
int a[N];
typedef pair<int, int> pii;
pii asn[N];
struct improve
{
	int type, id, a;
	long long b;
	bool operator<(const improve &rhs) const
	{
		return a * rhs.b > b * rhs.a;
	}
} b[N];
vector<pii> add[N];
int main()
{
	ios::sync_with_stdio(false);
	int k, n, m;
	cin >> k >> n >> m;
	for (int i = 1; i <= k; i++)
		cin >> a[i];
	int cc = 0;
	for (int i = 1; i <= n; i++)
	{
		int opt, id, val;
		cin >> opt >> id >> val;
		if (opt == 1)
			asn[id] = max(asn[id], make_pair(val, i));
		else if (opt == 2)
			add[id].push_back(make_pair(val, i));
		else
			b[++cc] = {3, i, val - 1, 1};
	}
	for (int i = 1; i <= k; i++)
		if (asn[i].first > a[i])
			b[++cc] = {1, asn[i].second, asn[i].first - a[i], a[i]};
	for (int i = 1; i <= k; i++)
	{
		sort(add[i].begin(), add[i].end());
		long long sum = a[i];
		for (int j = add[i].size() - 1; j >= 0; j--)
		{
			b[++cc] = {2, add[i][j].second, add[i][j].first, sum};
			sum += add[i][j].first;
		}
	}
	sort(b + 1, b + cc + 1);
	m = min(m, cc);
	sort(b + 1, b + m + 1, [](const improve &lhs, const improve &rhs) { return lhs.type < rhs.type; });
	cout << m << endl;
	for (int i = 1; i <= m; i++)
		cout << b[i].id << ' ';
	cout << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 100005;
int a[N];
typedef pair<int, int> pii;
pii asn[N];
struct improve
{
	int type, id, a;
	long long b;
	bool operator<(const improve &rhs) const
	{
		return a * rhs.b > b * rhs.a;
	}
} b[N];
vector<pii> add[N];
int main()
{
	ios::sync_with_stdio(false);
	int k, n, m;
	cin >> k >> n >> m;
	for (int i = 1; i <= k; i++)
		cin >> a[i];
	int cc = 0;
	for (int i = 1; i <= n; i++)
	{
		int opt, id, val;
		cin >> opt >> id >> val;
		if (opt == 1)
			asn[id] = max(asn[id], make_pair(val, i));
		else if (opt == 2)
			add[id].push_back(make_pair(val, i));
		else
			b[++cc] = {3, i, val - 1, 1};
	}
	for (int i = 1; i <= k; i++)
		if (asn[i].first > a[i])
			add[i].push_back(make_pair(asn[i].first - a[i], -asn[i].second));
	for (int i = 1; i <= k; i++)
	{
		sort(add[i].begin(), add[i].end());
		long long sum = a[i];
		for (int j = add[i].size() - 1; j >= 0; j--)
		{
			if (add[i][j].second > 0)
				b[++cc] = {2, add[i][j].second, add[i][j].first, sum};
			else
				b[++cc] = {1, -add[i][j].second, add[i][j].first, sum};
			sum += add[i][j].first;
		}
	}
	sort(b + 1, b + cc + 1);
	m = min(m, cc);
	sort(b + 1, b + m + 1, [](const improve &lhs, const improve &rhs) { return lhs.type < rhs.type; });
	cout << m << endl;
	for (int i = 1; i <= m; i++)
		cout << b[i].id << ' ';
	cout << endl;
	return 0;
}


from math import factorial
def comb(n,r):
    if r > n:
        return 0
    return factorial(n)/(factorial(r)*factorial(n-r))

s=list(input())
count=1
fd={}
tdn = 10**9+7
l=len(s)
messedup = True

def factor(n):
    ans=1
    maxm = n//2
    for m in range(maxm,-1,-1):
        ns=n-m*2
        ans = (ans + int(comb(m+1, ns))) % tdn
    return ans

if True:
    i=0
    while i < l:
        if s[i] == "m" or s[i] == "w":
            messedup = False
            break
        if s[i] in ['n', 'u']:
            cur = i
            while s[cur] == s[i]:
                cur += 1
                if cur == l:
                    break
            if cur - i >= 2:
                if cur-i in fd:
                    val = fd[cur-i]
                else:
                    fd[cur-i] = factor(cur-i)
                    val = fd[cur-i]
                count = (count * val) % tdn
                i = cur
                continue
        i += 1

    if not messedup:
        print(0)
        quit()

print(count)


s = list(input())
count = 1
fd = {}
tdn = 10 ** 9 + 7
l = len(s)
messedup = True

m1,m2=1,1

if len(s) < 2:
    print("1")
    quit()

if 'm' in s[0]+s[1] or 'w' in s[0]+s[1]:
    print("0")
    quit()

if s[0] == s[1] and s[0] in ['n', 'u']:
    m1 = 2
m=1
if True:
    i = 2
    while i < l:
        if s[i] == "m" or s[i] == "w":
            messedup = False
            break
        if s[i] in ['n', 'u']:
            if s[i-1] == s[i]:
                m = m1+m2
            else:
                m = m1
        else:
            m = m1
        m1, m2 = m, m1
        i += 1

    if not messedup:
        print(0)
        quit()

print(m)


s=list(input())
count=1
tdn = 10**9+7
l=len(s)
messedup = True
for i in range(l):
    if s[i] == "m" or s[i] == "w":
        messedup = False
        break
if not messedup:
    print(0)
    quit()

else:
    i=0
    while i < l:
        if s[i] in ['n', 'u']:
            cur = i
            while s[cur] == s[i]:
                cur += 1
                if cur == l:
                    break
            if cur - i >= 2:
                count = (count*(cur-i))
                i = cur
                continue
        i += 1

print(count % tdn)


s = input()
if 'm' in s or 'w' in s:
    print(0)
    exit()
a = []
prev = s[0]
b = 0
if s[0] == 'n' or s[0] == 'u':
    b = 1
for i in range(1, len(s)):
    if s[i] == 'n' and prev == 'n':
        b += 1
    elif s[i] == 'u' and prev == 'u':
        b += 1
    else:
        if b > 1:
            a += [b]
        b = 1
    prev = s[i]
if b > 1:
    a += [b]
if not a:
    print(1)
    exit()

ans2 = []
p = 0
for i in a:
    ans2.append(1)
    if i % 2 == 0:
        ans2[p] += 1
    j = 1
    while j * 2 < i:
        ans2[p] += (i - (j * 2)) * (j + 1)
        j += 1
    p += 1
ans = 1
for i in ans2:
    ans *= i
print(ans)


s = input()
if 'm' in s or 'w' in s:
    print(0)
    exit()
a = []
prev = s[0]
b = 0
if s[0] == 'n' or s[0] == 'u':
    b = 1
for i in range(1, len(s)):
    if s[i] == 'n' and prev == 'n':
        b += 1
    elif s[i] == 'u' and prev == 'u':
        b += 1
    else:
        if b > 1:
            a += [b]
        b = 1
    prev = s[i]
if b > 1:
    a += [b]
if not a:
    print(1)
    exit()

ans2 = []
p = 0
for i in a:
    ans2.append(1)
    if i % 2 == 0:
        ans2[p] += 1
    j = 1
    while j * 2 < i:
        ans2[p] += (i - (j * 2)) * (j + 1)
        j += 1
    p += 1
ans = 1
for i in ans2:
    ans *= i
print(ans % 1000000007)


s = input()
if 'm' in s or 'w' in s:
    print(0)
    exit()
a = []
prev = s[0]
b = 0
if s[0] == 'n' or s[0] == 'u':
    b = 1
for i in range(1, len(s)):
    if s[i] == 'n' and prev == 'n':
        b += 1
    elif s[i] == 'u' and prev == 'u':
        b += 1
    else:
        if b > 1:
            a += [b]
        b = 1
    prev = s[i]
if b > 1:
    a += [b]
if not a:
    print(1)
    exit()

ans2 = []
p = 0
for i in a:
    ans2.append(1)
    if i % 2 == 0:
        ans2[p] += 1
    j = 1
    while j * 2 < i:
        ans2[p] += (i - (j * 2)) * (j + 1)
        j += 1
    p += 1
ans = 1
for i in ans2:
    ans *= i
    ans %= 1000000007
print(ans % 1000000007)


s = input()
if 'm' in s or 'w' in s:
    print(0)
    exit()
a = []
prev = s[0]
b = 0
if s[0] == 'n' or s[0] == 'u':
    b = 1
for i in range(1, len(s)):
    if s[i] == 'n' and prev == 'n':
        b += 1
    elif s[i] == 'u' and prev == 'u':
        b += 1
    else:
        if b > 1:
            a += [b]
        b = 1
    prev = s[i]
if b > 1:
    a += [b]
if not a:
    print(1)
    exit()
ans = 0
for i in a:
    ans += 1
    if i % 2 == 0:
        ans += 1
    j = 1
    while j * 2 <= i:
        ans += (i - (j * 2)) * (j + 1) % 1000000007
        j += 1
print(ans % 1000000007)


s = input()
if 'm' in s or 'w' in s:
    print(0)
    exit()
a = []
prev = s[0]
b = 0
if s[0] == 'n' or s[0] == 'u':
    b = 1
for i in range(1, len(s)):
    if s[i] == 'n' and prev == 'n':
        b += 1
    elif s[i] == 'u' and prev == 'u':
        b += 1
    else:
        if b > 1:
            a += [b]
        b = 1
    prev = s[i]
if b > 1:
    a += [b]
if not a:
    print(1)
    exit()
ans = 1
ans2 = []
p = 0
for i in a:
    ans2.append(1)
    if i % 2 == 0:
        ans2[p] += 1
    j = 1
    while j * 2 < i:
        ans2[p] += (i - (j * 2)) * (j + 1) % 1000000007
        j += 1
    p += 1
for i in ans2:
    ans *= i
    ans %= 1000000007
print(ans % 1000000007)


s = input()
if 'm' in s or 'w' in s:
    print(0)
    exit()
a = []
prev = s[0]
b = 0
if s[0] == 'n' or s[0] == 'u':
    b = 1
for i in range(1, len(s)):
    if s[i] == 'n' and prev == 'n':
        b += 1
    elif s[i] == 'u' and prev == 'u':
        b += 1
    else:
        if b > 1:
            a += [b]
        b = 1
    prev = s[i]
if b > 1:
    a += [b]
if not a:
    print(1)
    exit()
ans = 1
for i in a:
    ans += 1
    if i % 2 == 0:
        ans += 1
    j = 1
    while j * 2 <= i:
        ans *= (i - (j * 2)) * (j + 1) % 1000000007
        j += 1
print(ans % 1000000007)


s=list(str(input()))
l=len(s)
k=0
def f(k):
    a=1
    b=1
    for i in range(k):
        c=a+b
        a,b=c,a
    return c
an=1
for i in range(l-1):
    if s[i]==s[i+1]=='n'or s[i]==s[i+1]=='u':
        k+=1
    elif k:
        an*=f(k)
        k=0
    if s[i]in['w','m']:
        an=0
        break
if k:
    an*=f(k)
print(an)


s=list(str(input()))
l=len(s)
k=0
def f(k):
    a=1
    b=1
    for i in range(k):
        c=a+b
        a,b=c,a
    return c
an=1
for i in range(l-1):
    if s[i]==s[i+1]=='n'or s[i]==s[i+1]=='u':
        k+=1
    elif k:
        an*=f(k)
        k=0
    if s[i]in['w','m']:
        an=0
        break
if k:
    an*=f(k)
print(an%(10**9+7))


s=list(str(input()))
l=len(s)
k=0
def f(k):
    a=1
    b=1
    for i in range(k):
        c=a+b
        a,b=c,a
    return c
an=1
for i in range(l-1):
    if s[i]==s[i+1]=='n'or s[i]==s[i+1]=='u':
        k+=1
    elif k:
        an*=f(k)
        k=0
    if s[i]in['w','m']:
        an=0
        break
if k:
    an*=f(k)
print(an%10**7)


def get_b(n):
    r = []
    while n > 0:
        r.append(n & 1)
        n >>= 1
    return r

def get_next(m):
    return add_fib_mth_nth(m, m)

def make_fib_matrix(n):
    mat = [0, 1, 1]
    r = []
    for i in range(0, n):
        r.append(mat)
        mat = get_next(mat)
    return r

def add_fib_mth_nth(m, n):
    return [m[0] * n[0] + m[1] * n[1], m[2] * n[1] + m[1] * n[0], m[2] * n[2] + m[1] * n[1]]

def get_fib_from_bin_cache(b, d):
    z = [0, 0, 1]
    if 0 != len(b):
        for i in range(0, len(b)):
            if 1 == b[i]:
                z = add_fib_mth_nth(z, d[i])
    return z[1]

def get_p(n, d):
    return get_fib_from_bin_cache(get_b(n + 2), d)

dat = make_fib_matrix(20)
div = 10 ** 9 + 7
s = input()
last_char = ''
last_len = 0
fake = 'un'
real = 'wm'
a_mul = []
ret = 1

for c in s:
    if c in real:
        a_mul.clear()
        ret = 0
        break
    if c in fake:
        if c == last_char:
            last_len += 1
        elif last_len > 0:
            a_mul.append(get_p(last_len, dat))
            last_len = 1
    else:
        if last_len > 0:
            a_mul.append(get_p(last_len, dat))
            last_len = 0
    last_char = c
if last_char in fake:
    a_mul.append(get_p(last_len, dat))

for i in a_mul:
    ret *= i
    ret %= div
print(ret)


def get_b(n):
    r = []
    while n > 0:
        r.append(n & 1)
        n >>= 1
    return r

def get_next(m):
    return add_fib_mth_nth(m, m)

def make_fib_matrix(n):
    mat = [0, 1, 1]
    r = []
    for i in range(0, n):
        r.append(mat)
        mat = get_next(mat)
    return r

def add_fib_mth_nth(m, n):
    return [m[0] * n[0] + m[1] * n[1], m[2] * n[1] + m[1] * n[0], m[2] * n[2] + m[1] * n[1]]

def get_fib_from_bin_cache(b, d):
    z = [0, 0, 1]
    if 0 != len(b):
        for i in range(0, len(b)):
            if 1 == b[i]:
                z = add_fib_mth_nth(z, d[i])
    return z[1]

def get_p(n, d):
    return get_fib_from_bin_cache(get_b(n + 1), d)

dat = make_fib_matrix(20)
div = 10 ** 9 + 7
s = input()
fake = 'un'
real = 'wm'
a_mul = []
ret = 1
head = 0

while head < len(s) - 1:
    if s[head] in real:
        a_mul.clear()
        break
    if s[head] in fake:
        l_seg = 1
        while head + l_seg < len(s) and s[head + l_seg] == s[head]:
            l_seg += 1
        a_mul.append(get_p(l_seg, dat))
        head += l_seg
    head += 1

if len(a_mul) == 0:
    print(0)
else:
    for i in a_mul:
        ret *= i
        ret %= div
    print(ret)


def get_b(n):
    r = []
    while n > 0:
        r.append(n & 1)
        n >>= 1
    return r

def get_next(m):
    return add_fib_mth_nth(m, m)

def make_fib_matrix(n):
    mat = [0, 1, 1]
    r = []
    for i in range(0, n):
        r.append(mat)
        mat = get_next(mat)
    return r

def add_fib_mth_nth(m, n):
    return [m[0] * n[0] + m[1] * n[1], m[2] * n[1] + m[1] * n[0], m[2] * n[2] + m[1] * n[1]]

def get_fib_from_bin_cache(b, d):
    z = [0, 0, 1]
    if 0 != len(b):
        for i in range(0, len(b)):
            if 1 == b[i]:
                z = add_fib_mth_nth(z, d[i])
    return z[1]

def get_p(n, d):
    return get_fib_from_bin_cache(get_b(n + 1), d)

dat = make_fib_matrix(20)
div = 10 ** 9 + 7
s = input()
fake = 'un'
real = 'wm'
a_mul = []
ret = 1
head = 0

while head < len(s) - 1:
    if s[head] in real:
        ret = 0
        break
    if s[head] in fake:
        l_seg = 1
        while head + l_seg < len(s) and s[head + l_seg] == s[head]:
            l_seg += 1
        a_mul.append(get_p(l_seg, dat))
        head += l_seg
    else:
        head += 1

for i in a_mul:
    ret *= i
print(ret % div)


def get_b(n):
    r = []
    while n > 0:
        r.append(n & 1)
        n >>= 1
    return r

def get_next(m):
    return add_fib_mth_nth(m, m)

def make_fib_matrix(n):
    mat = [0, 1, 1]
    r = []
    for i in range(0, n):
        r.append(mat)
        mat = get_next(mat)
    return r

def add_fib_mth_nth(m, n):
    return [m[0] * n[0] + m[1] * n[1], m[2] * n[1] + m[1] * n[0], m[2] * n[2] + m[1] * n[1]]

def get_fib_from_bin_cache(b, d):
    z = [0, 0, 1]
    if 0 != len(b):
        for i in range(0, len(b)):
            if 1 == b[i]:
                z = add_fib_mth_nth(z, d[i])
    return z[1]

def get_p(n, d):
    return get_fib_from_bin_cache(get_b(n + 1), d)

dat = make_fib_matrix(20)
div = 10 ** 9 + 7
s = input()
fake = 'un'
real = 'wm'
a_mul = []
ret = 1
head = 0

while head < len(s) - 1:
    if s[head] in real:
        ret = 0
        break
    if s[head] in fake:
        l_seg = 1
        while head + l_seg < len(s) and s[head + l_seg] == s[head]:
            l_seg += 1
        a_mul.append(get_p(l_seg, dat))
        head += l_seg
    head += 1

for i in a_mul:
    ret *= i
    ret %= div
print(ret)


import sys
sys.setrecursionlimit(100000)

def f(i):
    if i == n:
        return 1
    if dp[i] != -1:
        return dp[i]

    ans = f(i+1)
    if s[i]=='u':
        if i+1 < n and s[i+1] == 'u':
            ans += f(i+2)
    if s[i]=='n':
        if i+1 < n and s[i+1] == 'n':
            ans += f(i+2)
    dp[i] = ans%(10**9 + 7)
    return ans

s = input()
n = len(s)
if 'm' in s or 'w' in s:
    print(0)
else:
    dp = [-1 for i in range(n+1)]
    print(f(0)%(10**9 + 7))


def f(i):
    if i == n:
        return 1
    if dp[i] != -1:
        return dp[i]

    ans = f(i+1)
    if s[i]=='u':
        if i+1 < n and s[i+1] == 'u':
            ans += f(i+2)
    if s[i]=='n':
        if i+1 < n and s[i+1] == 'n':
            ans += f(i+2)
    dp[i] = ans%(10**9 + 7)
    return ans

s = input()
n = len(s)
if 'm' in s or 'w' in s:
    print(0)
else:
    dp = [-1 for i in range(n+1)]
    print(f(0)%(10**9 + 7))


import sys
sys.setrecursionlimit(100000)

def f(i):
    if i == n:
        return 1
    if dp[i] != -1:
        return dp[i]
    MOD = 10**9 + 7
    ans = f(i+1)
    ans %= MOD
    if s[i]=='u':
        if i+1 < n and s[i+1] == 'u':
            ans += f(i+2)
            ans %= MOD
    if s[i]=='n':
        if i+1 < n and s[i+1] == 'n':
            ans += f(i+2)
            ans %= MOD
    dp[i] = ans%(10**9 + 7)
    return ans

s = input()
n = len(s)
if 'm' in s or 'w' in s:
    print(0)
else:
    dp = [-1 for i in range(n+1)]
    MOD = 10**9 + 7
    for i in range(n, -1, -1):
        if i==n:
            dp[i] = 1
        else:
            dp[i] = dp[i+1]%MOD
            if s[i] == 'u':
                if i+1 < n and s[i+1] == 'u':
                    dp[i] += dp[i+2]
                    dp[i] %= MOD
            if s[i] == 'n':
                if i+1 < n and s[i+1] == 'n':
                    dp[i] += dp[i+2]
                    dp[i] %= MOD

    print(dp[0]%(10**9 + 7))


import sys
sys.setrecursionlimit(100000)

def f(i):
    if i == n:
        return 1
    if dp[i] != -1:
        return dp[i]
    MOD = 10**9 + 7
    ans = f(i+1)
    ans %= MOD
    if s[i]=='u':
        if i+1 < n and s[i+1] == 'u':
            ans += f(i+2)
            ans %= MOD
    if s[i]=='n':
        if i+1 < n and s[i+1] == 'n':
            ans += f(i+2)
            ans %= MOD
    dp[i] = ans%(10**9 + 7)
    return ans

s = input()
n = len(s)
if 'm' in s or 'w' in s:
    print(0)
else:
    dp = [-1 for i in range(n+1)]
    print(f(0)%(10**9 + 7))


s = input()+'1'
d = {}
prev = s[0]
if prev in ['w','m']:
    print(0)
else:
    s1 = 0
    f = 0
    if prev in ['u','n']:
        s1+=1
    for i in s[1:]:
        if i in ['w','m']:
            print(0)
            f = 1
            break
        if i in ['u','n'] and i==prev:
                s1 += 1
        else:
            if s1>1:
                if s1 in d:
                    d[s1] += 1
                else:
                    d[s1] = 1
            s1 = 1
        prev = i
    if f==0:
        p = 1
        if d:
            n = max(d.keys())
            fib = [1]*(n+1)
            for i in range(2,n+1):
                fib[i] = fib[i-1]+fib[i-2]
            for i in d:
                v = fib[i]**d[i]
                p*=v
        print(p)


s = input()+'1'
mod = 10**9+7
d = {}
prev = s[0]
if prev in ['w','m']:
    print(0)
else:
    s1 = 0
    f = 0
    if prev in ['u','n']:
        s1+=1
    for i in s[1:]:
        if i in ['w','m']:
            print(0)
            f = 1
            break
        if i in ['u','n'] and i==prev:
                s1 += 1
        else:
            if s1>1:
                if s1 in d:
                    d[s1] += 1
                else:
                    d[s1] = 1
            s1 = 1
        prev = i
    if f==0:
        p = 1
        if d:
            n = max(d.keys())
            fib = [1]*(n+1)
            for i in range(2,n+1):
                fib[i] = fib[i-1]+fib[i-2]
            for i in d:
                v = fib[i]**d[i]
                p*=v
                p%=mod
        print(p)


from sys import stdin
input = stdin.readline
s = input()+'1'
mod = 10**9+7
d = {}
prev = s[0]
if prev in ['w','m']:
    print(0)
else:
    s1 = 0
    f = 0
    if prev in ['u','n']:
        s1+=1
    for i in s[1:]:
        if i in ['w','m']:
            print(0)
            f = 1
            break
        if i in ['u','n'] and i==prev:
                s1 += 1
        else:
            if s1>1:
                if s1 in d:
                    d[s1] += 1
                else:
                    d[s1] = 1
            s1 = 1
        prev = i
    if f==0:
        p = 1
        if d:
            n = max(d.keys())
            fib = {0:1,1:1}
            a,b = 1,1
            for i in range(2,n+1):
                c = a+b
                if i in d:
                    fib[i]=c
                a = b
                b = c
            for i in d:
                v = fib[i]**d[i]
                p*=v
                p%=mod
        print(p)


from sys import stdin
input = stdin.readline
s = input()+'1'
mod = 10**9+7
d = {}
prev = s[0]
if prev in ['w','m']:
    print(0)
else:
    s1 = 0
    f = 0
    if prev in ['u','n']:
        s1+=1
    for i in s[1:]:
        if i in ['w','m']:
            print(0)
            f = 1
            break
        if i in ['u','n'] and i==prev:
                s1 += 1
        else:
            if s1>1:
                if s1 in d:
                    d[s1] += 1
                else:
                    d[s1] = 1
            s1 = 1
        prev = i
    if f==0:
        p = 1
        if d:
            n = max(d.keys())
            fib = [1]*(n+1)
            for i in range(2,n+1):
                fib[i] = fib[i-1]+fib[i-2]
            for i in d:
                v = fib[i]**d[i]
                p*=v
                p%=mod
        print(p)


from math import ceil,floor
t=int(input())
while t:
    n=int(input())
    l=list(map(int,input().split()))
    st=input()
    r=st.count('R')
    p=st.count('P')
    s=st.count('S')
    ext=[]
    if(n==1):
        l.append(0)
        l.append(0)
    if(n==2):
        l.append(0)
    su=min(s,l[0])
    ext.append(l[0]-s)
    if(n>1):
        su+=min(r,l[1])
    ext.append(l[1]-r)
    if(n>2):
        su+=min(p,l[2])
    ext.append(l[2]-p)
    #print(su,l,s,p,r,ext)
    #val=round(n/2, 0)
    #val=int(val)
    if(ceil(n/2)-n/2==n/2-floor(n/2)) or (ceil(n/2)-n/2<n/2-floor(n/2)):
        val=ceil(n/2)
    else:
        val=floor(n/2)
    if(val>su):
        print("NO")
    else:
        print("YES")
        for i in range(len(st)):
            if(st[i]=='P' and l[2]!=0):
                print('S',end="")
                l[2]-=1
                #print("lol")
            elif(st[i]=='P' and l[2]==0):
                if(ext[0]>0):
                    print('R',end="")
                    ext[0]-=1
                elif(ext[1]>0):
                    print('P',end="")
                    ext[1]-=1
                elif(ext[2]>0):
                    print('S',end="")
                    ext[2]-=1
            elif(st[i]=='S' and l[0]!=0):
                print('R',end="")
                l[0]-=1
                #print("lol")
            elif(st[i]=='S' and l[0]==0):
                if(ext[0]>0):
                    print('R',end="")
                    ext[0]-=1
                elif(ext[1]>0):
                    print('P',end="")
                    ext[1]-=1
                elif(ext[2]>0):
                    print('S',end="")
                    ext[2]-=1
            elif(st[i]=='R' and l[1]!=0):
                print('P',end="")
                l[1]-=1
                #print("lol")
            elif(st[i]=='R' and l[1]==0):
                if(ext[0]>0):
                    print('R',end="")
                    ext[0]-=1
                elif(ext[1]>0):
                    print('P',end="")
                    ext[1]-=1
                elif(ext[2]>0):
                    print('S',end="")
                    ext[2]-=1
            #print(st[i],l[2],ext)
            #print(ext,l)
        print()
    t-=1


from math import ceil,floor
t=int(input())
while t:
    n=int(input())
    l=list(map(int,input().split()))
    st=input()
    r=st.count('R')
    p=st.count('P')
    s=st.count('S')
    ext=[]
    if(n==1):
        l.append(0)
        l.append(0)
    if(n==2):
        l.append(0)
    su=min(s,l[0])
    ext.append(l[0]-s)
    if(n>1):
        su+=min(r,l[1])
        ext.append(l[1]-r)
    else:
        ext.append(0)
    if(n>2):
        su+=min(p,l[2])
        ext.append(l[2]-p)
    else:
        ext.append(0)
    #print(su,l,s,p,r,ext)
    if(ceil(n/2)-n/2==n/2-floor(n/2) or ceil(n/2)-n/2<n/2-floor(n/2)):
        val=ceil(n/2)
    else:
        val=floor(n/2)
    #print(val,su)
    if(val>su):
        print("NO")
    else:
        print("YES")
        for i in range(len(st)):
            if(st[i]=='P' and l[2]!=0):
                print('S',end="")
                l[2]-=1
                #print("lol")
            elif(st[i]=='P' and l[2]==0):
                if(ext[0]>0):
                    print('R',end="")
                    ext[0]-=1
                elif(ext[1]>0):
                    print('P',end="")
                    ext[1]-=1
                elif(ext[2]>0):
                    print('S',end="")
                    ext[2]-=1
            elif(st[i]=='S' and l[0]!=0):
                print('R',end="")
                l[0]-=1
                #print("lol")
            elif(st[i]=='S' and l[0]==0):
                if(ext[0]>0):
                    print('R',end="")
                    ext[0]-=1
                elif(ext[1]>0):
                    print('P',end="")
                    ext[1]-=1
                elif(ext[2]>0):
                    print('S',end="")
                    ext[2]-=1
            elif(st[i]=='R' and l[1]!=0):
                print('P',end="")
                l[1]-=1
                #print("lol")
            elif(st[i]=='R' and l[1]==0):
                if(ext[0]>0):
                    print('R',end="")
                    ext[0]-=1
                elif(ext[1]>0):
                    print('P',end="")
                    ext[1]-=1
                elif(ext[2]>0):
                    print('S',end="")
                    ext[2]-=1
            #print(st[i],l[2],ext)
            #print(ext,l)
        print()
    t-=1


from math import ceil
m=1000000007
fact=[1]
for i in range(1,100005):
    fact.append((fact[-1]*i)%m)
#print(fact)
def val(i):
    k=0
    #print(i)
    su=0
    for j in range(i+1,-1,-1):
        if(j<k):
            break
        su+=(fact[j]/(fact[k]*fact[j-k]))
        #print(su)
        k+=1
    return su
s=input()
cou=1
l=[]
mi=0
lol=0
if(s[0]=='m' or s[0]=='w'):
    lol=1

for i in range(1,len(s)):
    if(s[i]=='m' or s[i]=='w'):
        lol=1
    if((s[i]=='u' and s[i-1]=='u') or (s[i]=='n' and s[i-1]=='n')):
        cou+=1
    else:
        l.append(cou-1)
        if(cou-1>=1):
            mi=1
        cou=1
l.append(cou-1)
if(cou-1>=1):
    mi=1
res=1
for i in range(len(l)):
    if(l[i]>=1):
        res=res*(2**l[i])

    mi=mi*(2**l[i]-val(l[i]))
#print(res,mi)
if(lol):
    print(0)
else:

    print(int(res-mi)%m)


s=input()
if(s.count('w') or s.count('m')):
    print(0)
else:
    dp=[1,1]
    n=len(s)
    for i in range(1,n):
        if(s[i]==s[i-1] and (s[i]=='u' or s[i]=='n')):
            dp.append(dp[i]+dp[i-1])
        else:
            dp.append(dp[i])
    #print(dp)
    print(dp[-1])


m=1000000007
s=input()
if(s.count('w') or s.count('m')):
    print(0)
else:
    dp=[1,1]
    n=len(s)
    for i in range(1,n):
        if(s[i]==s[i-1] and (s[i]=='u' or s[i]=='n')):
            dp.append((dp[i]+dp[i-1])%m)
        else:
            dp.append(dp[i]%m)
    #print(dp)
    print(dp[-1]%m)


import re
from functools import reduce, lru_cache

M = int(1e9+7)

@lru_cache(maxsize=None)
def w(n):
    if n < 5: return (1, 1, 2, 3, 5, 8)[n]
    a = n//2
    b = n-a
    return (w(a)*w(b) + w(a-1)*w(b-1)) % M

s = input().strip()

if 'm' in s or 'w' in s: print(0)
else:
    s = [w(len(l)) for l in re.findall(r'u+|n+', s)]
    print(reduce(lambda a,b: a * b % M, s, 1))


import re
from functools import reduce, lru_cache

@lru_cache(maxsize=None)
def w(n):
    if n < 5: return (1, 1, 2, 3, 5, 8)[n]
    a = n//2
    b = n-a
    return (w(a)*w(b) + w(a-1)*w(b-1)) % 1000000007

s = input().strip()

if 'm' in s or 'w' in s: print(0)
else:
    s = [w(len(l)) for l in re.findall(r'u+|n+', s)]
    print(reduce(lambda a,b: a*b%1000000007, s, 1))


import operator as op
import re
from functools import reduce, lru_cache

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

@lru_cache(maxsize=None)
def w(n):
    if n < 5: return sum(ncr(n-i, i) for i in range(n//2+1))
    a = n//2
    b = n-a
    return (w(a)*w(b) + w(a-1)*w(b-1)) % 1000000007

s = input().strip()

if 'm' in s or 'w' in s: print(0)
else:
    s = [w(len(l)) for l in re.split(r'[^nu]', s)]
    print(reduce(op.mul, s, 1))


import operator as op
import re
from functools import reduce, lru_cache

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

@lru_cache(maxsize=None)
def w(n):
    if n < 5: return sum(ncr(n-i, i) for i in range(n//2+1))
    a = n//2
    b = n-a
    return (w(a)*w(b) + w(a-1)*w(b-1)) % 1000000007

s = input().strip()

if 'm' in s or 'w' in s: print(0)
else:
    s = [w(len(l)) for l in re.findall(r'u+|n+', s)]
    print(reduce(op.mul, s, 1) % 1000000007)


import operator as op
import re
from functools import reduce, lru_cache

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

@lru_cache(maxsize=None)
def w(n):
    if n < 5: return sum(ncr(n-i, i) for i in range(n//2+1))
    a = n//2
    b = n-a
    return (w(a)*w(b) + w(a-1)*w(b-1)) % 1000000007

s = input().strip()

if 'm' in s or 'w' in s: print(0)
else:
    s = [w(len(l)) for l in re.findall(r'u+|n+', s)]
    print(reduce(op.mul, s, 1))


def dp_f(x, M):

    memo = {}

    def f(z):
        if z in memo.keys():
            return memo[z]
        elif z <= 1:
            return 1
        elif x > 1:
            return (f(z - 2) + f(z - 1)) % M

    for i in range(x):
        f(i)

    return f(x)

s = input()
n = len(s)
c = 0
d = 0
ans = 1
for i in range(n):
    if s[i] == 'n':
        c += 1
    elif c > 0:
        ans = (ans * dp_f(c, 10 ** 9 + 7)) % (10 ** 9 + 7)
        c = 0
    if s[i] == 'u':
        d += 1
    elif d > 0:
        ans = (ans * dp_f(d, 10 ** 9 + 7)) % (10 ** 9 + 7)
        d = 0
if c > 0:
    ans = (ans * dp_f(c, 10 ** 9 + 7)) % (10 ** 9 + 7)
if d > 0:
    ans = (ans * dp_f(d, 10 ** 9 + 7)) % (10 ** 9 + 7)
if 'm' in s or 'w' in s:
    ans = 0
print(ans)


def dp_f(x, M):

    memo = {}

    def f(z):
        if z in memo.keys():
            return memo[z]
        elif z <= 1:
            return 1
        elif z > 1:
            m = (f(z - 2) + f(z - 1)) % M
            memo[z] = m
            return m

    for i in range(x):
        f(i)

    return f(x)

s = input()
n = len(s)
c = 0
d = 0
ans = 1
for i in range(n):
    if s[i] == 'n':
        c += 1
    elif c > 0:
        ans = (ans * dp_f(c, 10 ** 9 + 7)) % (10 ** 9 + 7)
        c = 0
    if s[i] == 'u':
        d += 1
    elif d > 0:
        ans = (ans * dp_f(d, 10 ** 9 + 7)) % (10 ** 9 + 7)
        d = 0
if c > 0:
    ans = (ans * dp_f(c, 10 ** 9 + 7)) % (10 ** 9 + 7)
if d > 0:
    ans = (ans * dp_f(d, 10 ** 9 + 7)) % (10 ** 9 + 7)
if 'm' in s or 'w' in s:
    ans = 0
print(ans)


from sys import stdin

def get_int():
    return int(stdin.readline().strip())

def get_tuple():
    return map(int, stdin.readline().split())

def get_list():
    return list(map(int, stdin.readline().split()))

def solve(n,m):
    if n>=m:
        return n-m
    if m%2:
        return 1+solve(n,m+1)
    return 1+solve(n,m//2)

def main():
    st = input()
    if st.count('m')>0 or st.count('w')>0:
        print(0)
    else:
        n = len(st)
        dp = [1,1] + [0]*(n-1)
        for i in range(2,n+1):
            dp[i] = dp[i-1]
            if st[i-1]==st[i-2] and (st[i-1]=='u' or st[i-1]=='n'):
                dp[i] = dp[i-1]+dp[i-2]
        print(dp[-1])

TestCases = False

if TestCases:
    for i in range(get_int()):
        main()
else:
    main()


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
    return int(stdin.readline().strip())

def get_tuple():
    return map(int, stdin.readline().split())

def get_list():
    return list(map(int, stdin.readline().split()))

def solve(n,m):
    if n>=m:
        return n-m
    if m%2:
        return 1+solve(n,m+1)
    return 1+solve(n,m//2)

def main():
    st = input()
    if st.count('m')>0 or st.count('w')>0:
        print(0)
    else:
        n = len(st)
        dp = [1,1] + [0]*(n-1)
        for i in range(2,n+1):
            dp[i] = dp[i-1]
            if st[i-1]==st[i-2] and (st[i-1]=='u' or st[i-1]=='n'):
                dp[i] = dp[i-1]+dp[i-2]
        print(dp[-1])

TestCases = False

if TestCases:
    for i in range(get_int()):
        main()
else:
    main()


from sys import stdin

def get_int():
    return int(stdin.readline().strip())

def get_tuple():
    return map(int, stdin.readline().split())

def get_list():
    return list(map(int, stdin.readline().split()))

def solve(n,m):
    if n>=m:
        return n-m
    if m%2:
        return 1+solve(n,m+1)
    return 1+solve(n,m//2)

MOD = 10**9+7
def main():
    st = input()
    if st.count('m')>0 or st.count('w')>0:
        print(0)
    else:
        n = len(st)
        dp = [1,1] + [0]*(n-1)
        for i in range(2,n+1):
            dp[i] = dp[i-1]
            if st[i-1]==st[i-2] and (st[i-1]=='u' or st[i-1]=='n'):
                dp[i] = (dp[i-1]+dp[i-2])%MOD
        print(dp[-1])

TestCases = False

if TestCases:
    for i in range(get_int()):
        main()
else:
    main()


import sys

# def recur(pre,p,pos,maxx,temp):
#     if pos == len(pre):
#         maxx[0] = max(maxx[0],temp)
#         return

#     for i in range(0,p+1):
#         if i < len(pre[pos]) :
#             temp = temp + pre[pos][i]
#             recur(pre,p-i,pos+1,maxx,temp)
#             temp = temp - pre[pos][i]

RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

# for _ in range(int(ri())):

st = ri()
dp = [0]*2
dp[1] = 1
for i in range(len(st)):
    if st[i] == 'm' or st[i] == 'w':
        break
    if st[i] == 'n' and st[i-1] == 'n':
        temp = dp[1]
        dp[1] = dp[0]+dp[1]
        dp[0] = temp
    elif st[i] == 'u' and st[i-1] == 'u':
        temp = dp[1]
        dp[1] = dp[0]+dp[1]
        dp[0] = temp
    else:
        dp[0] = dp[1]

print(dp[1])


import sys

# def recur(pre,p,pos,maxx,temp):
#     if pos == len(pre):
#         maxx[0] = max(maxx[0],temp)
#         return

#     for i in range(0,p+1):
#         if i < len(pre[pos]) :
#             temp = temp + pre[pos][i]
#             recur(pre,p-i,pos+1,maxx,temp)
#             temp = temp - pre[pos][i]

RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

# for _ in range(int(ri())):

mod = 10**9+7
st = ri()
dp = [0]*2
dp[1] = 1
for i in range(len(st)):
    if st[i] == 'm' or st[i] == 'w':
        dp[1] = 0
        break
    if st[i] == 'n' and st[i-1] == 'n':
        temp = dp[1]
        dp[1] = (dp[0]+dp[1])%mod
        dp[0] = temp
    elif st[i] == 'u' and st[i-1] == 'u':
        temp = dp[1]
        dp[1] = (dp[0]+dp[1])%mod
        dp[0] = temp
    else:
        dp[0] = dp[1]

print(dp[1])


import sys

# def recur(pre,p,pos,maxx,temp):
#     if pos == len(pre):
#         maxx[0] = max(maxx[0],temp)
#         return

#     for i in range(0,p+1):
#         if i < len(pre[pos]) :
#             temp = temp + pre[pos][i]
#             recur(pre,p-i,pos+1,maxx,temp)
#             temp = temp - pre[pos][i]

RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

# for _ in range(int(ri())):

st = ri()
dp = [0]*(len(st)+1)
dp[0] = 1
for i in range(len(st)):
    if st[i] == 'm' or st[i] == 'w':
        break
    if st[i] == 'n' and st[i-1] == 'n':
        dp[i+1] = dp[i]+dp[i-1]
    elif st[i] == 'u' and st[i-1] == 'u':
        dp[i+1] = dp[i-1]+dp[i]
    else:
        dp[i+1] = dp[i]

print(dp[len(st)])


import sys

# def recur(pre,p,pos,maxx,temp):
#     if pos == len(pre):
#         maxx[0] = max(maxx[0],temp)
#         return

#     for i in range(0,p+1):
#         if i < len(pre[pos]) :
#             temp = temp + pre[pos][i]
#             recur(pre,p-i,pos+1,maxx,temp)
#             temp = temp - pre[pos][i]

RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

# for _ in range(int(ri())):

st = ri()
dp = [0]*2
dp[1] = 1
for i in range(len(st)):
    if st[i] == 'm' or st[i] == 'w':
        dp[1] = 0
        break
    if st[i] == 'n' and st[i-1] == 'n':
        temp = dp[1]
        dp[1] = dp[0]+dp[1]
        dp[0] = temp
    elif st[i] == 'u' and st[i-1] == 'u':
        temp = dp[1]
        dp[1] = dp[0]+dp[1]
        dp[0] = temp
    else:
        dp[0] = dp[1]

print(dp[1])


def fib(x1, x2, n):
    if n == 1:
        return x1
    if n == 2:
        return x2
    cur = 1
    while cur < n - 1:
        cur += 1
        x1, x2 = x2 , x1 + x2
    return x2

s = input()
i = 0
res = 1
for i in s:
    if i == 'm' or i == 'w':
        print(0)
        exit(0)
i = 0
while i < len(s):
    if s[i] == 'n':
        j = i
        c = 0
        while j < len(s) and s[j] == 'n':
            c += 1
            j += 1
            i += 1
        res *= fib(1, 2, c)
        continue
    if s[i] == 'u':
        j = i
        c = 0
        while j < len(s) and s[j] == 'u':
            c += 1
            j += 1
            i += 1
        res *= fib(1, 2, c)
        continue
    i += 1
print(res)


def fib(x1, x2, n):
    if n == 1:
        return x1
    if n == 2:
        return x2
    cur = 1
    while cur < n - 1:
        cur += 1
        x1, x2 = x2 , x1 + x2
    return x2

s = input()
i = 0
res = 1
for i in s:
    if i == 'm' or i == 'w':
        print(0)
        exit(1)
while i < len(s):
    if s[i] == 'n':
        j = i
        c = 0
        while j < len(s) and s[j] == 'n':
            c += 1
            j += 1
        i += j
        res *= fib(1, 2, c)
        continue
    if s[i] == 'u':
        j = i
        c = 0
        while j < len(s) and s[j] == 'u':
            c += 1
            j += 1
        i += j
        res *= fib(1, 2, c)
    i += 1
print(res)


def fib(x1, x2, n):
    if n == 1:
        return x1
    if n == 2:
        return x2
    cur = 1
    while cur < n - 1:
        cur += 1
        x1, x2 = x2 , x1 + x2
    return x2

s = input()
i = 0
res = 1
for i in s:
    if i == 'm' or i == 'w':
        print(0)
        exit(1)
i = 0
while i < len(s):
    if s[i] == 'n':
        j = i
        c = 0
        while j < len(s) and s[j] == 'n':
            c += 1
            j += 1
        i += j
        res *= fib(1, 2, c)
        continue
    if s[i] == 'u':
        j = i
        c = 0
        while j < len(s) and s[j] == 'u':
            c += 1
            j += 1
        i += j
        res *= fib(1, 2, c)
    i += 1
print(res)


def fib(x1, x2, n):
    if n == 1:
        return x1
    if n == 2:
        return x2
    cur = 1
    while cur < n - 1:
        cur += 1
        x1, x2 = x2 , x1 + x2
    return x2

s = input()
i = 0
res = 1
for i in s:
    if i == 'm' or i == 'w':
        print(0)
        exit(0)
i = 0
while i < len(s):
    if s[i] == 'n':
        j = i
        c = 0
        while j < len(s) and s[j] == 'n':
            c += 1
            j += 1
            i += 1
        res *= fib(1, 2, c)
        continue
    if s[i] == 'u':
        j = i
        c = 0
        while j < len(s) and s[j] == 'u':
            c += 1
            j += 1
            i += 1
        res *= fib(1, 2, c)
        continue
    i += 1
print(res % (10**9 + 7))


def fib(x1, x2, n):
    if n == 1:
        return x1
    if n == 2:
        return x2
    cur = 1
    while cur < n - 1:
        cur += 1
        x1, x2 = x2 , x1 + x2
    return x2

s = input()
i = 0
res = 1
for i in s:
    if i == 'm' or i == 'w':
        print(0)
        exit(0)
i = 0
while i < len(s):
    if s[i] == 'n':
        j = i
        c = 0
        while j < len(s) and s[j] == 'n':
            c += 1
            j += 1
        i += j
        res *= fib(1, 2, c)
        continue
    if s[i] == 'u':
        j = i
        c = 0
        while j < len(s) and s[j] == 'u':
            c += 1
            j += 1
        i += j
        res *= fib(1, 2, c)
    i += 1
print(res)


def fib(x1, x2, n):
    if n == 1:
        return x1
    if n == 2:
        return x2
    cur = 1
    while cur < n - 1:
        cur += 1
        x1, x2 = x2 , x1 + x2
    return x2

s = input()
i = 0
res = 1
for i in s:
    if i == 'm' or i == 'w':
        print(0)
        exit(0)
while i < len(s):
    if s[i] == 'n':
        j = i
        c = 0
        while j < len(s) and s[j] == 'n':
            c += 1
            j += 1
        i += j
        res *= fib(1, 2, c)
        continue
    if s[i] == 'u':
        j = i
        c = 0
        while j < len(s) and s[j] == 'u':
            c += 1
            j += 1
        i += j
        res *= fib(1, 2, c)
    i += 1
print(res)


from itertools import groupby
dp0 = [0, 1]
dp1 = [0, 0]
d0, d1 = 1, 0
A = [0, 1]
for i in range(2, 101010):
    d0, d1 = d0+d1, d0
    dp0.append(d0)
    dp1.append(d1)
    A.append(d0+d1)

S = input()
mod = 10**9+7
ans = 1
for c, g in groupby(S):
    if c=="n" or c=="u":
        n = len(list(g))
        ans = ans * A[n] % mod
print(ans)


from itertools import groupby
dp0 = [0, 1]
dp1 = [0, 0]
d0, d1 = 1, 0
A = [0, 1]
mod = 10**9+7
for i in range(2, 101010):
    d0, d1 = (d0+d1) % mod, d0
    dp0.append(d0)
    dp1.append(d1)
    A.append(d0+d1)

S = input()
ans = 1
for c, g in groupby(S):
    if c=="n" or c=="u":
        n = len(list(g))
        ans = ans * A[n] % mod
    elif c=="m" or c=="w":
        ans = 0
print(ans)


from itertools import groupby
dp0 = [0, 1]
dp1 = [0, 0]
d0, d1 = 1, 0
A = [0, 1]
mod = 10**9+7
for i in range(2, 101010):
    d0, d1 = (d0+d1) % mod, d0
    dp0.append(d0)
    dp1.append(d1)
    A.append(d0+d1)

S = input()
ans = 1
for c, g in groupby(S):
    if c=="n" or c=="u":
        n = len(list(g))
        ans = ans * A[n] % mod
print(ans)


from sys import stdin, exit

rem = 10**9 + 7
dp = {'norm': 1, 'last_n': 0, 'last_u': 0}

for i in stdin.readline().strip():
    if i in 'mw':
        print(0)
        exit(0)

    if i not in 'nu':
        dp = {
                'norm': (dp['norm'] + dp['last_n'] + dp['last_u']) % rem,
                'last_n': 0,
                'last_u': 0
        }
        continue

    if i == 'u':
        dp = {
                'norm': dp['last_u'],
                'last_u': (dp['last_u'] + dp['norm']) % rem,
                'last_n': 0
        }

    if i == 'n':
        dp = {
                'norm': dp['last_n'],
                'last_n': (dp['last_n'] + dp['norm']) % rem,
                'last_u': 0
        }
print((dp['norm'] + dp['last_u'] + dp['last_n']) % rem)


from sys import stdin, exit

rem = 10**9 + 7
dp = {'norm': 1, 'last_n': 0, 'last_u': 0}

for i in stdin.readline().strip():
    if i in 'mw':
        print(0)
        exit(0)

    if i not in 'nu':
        dp = {
                'norm': (dp['norm'] + dp['last_n'] + dp['last_u']) % rem,
                'last_n': 0,
                'last_u': 0
        }
        continue

    if i == 'u':
        dp = {
                'norm': (dp['last_u']) % rem,
                'last_u': (dp['last_u'] + dp['norm'] + dp['last_n']) % rem,
                'last_n': 0
        }

    if i == 'n':
        dp = {
                'norm': (dp['last_n']) % rem,
                'last_n': (dp['last_n'] + dp['norm'] + dp['last_u']) % rem,
                'last_u': 0
        }
print((dp['norm'] + dp['last_u'] + dp['last_n']) % rem)


from sys import stdin, exit

rem = 10**9 + 7
dp = {'norm': 1, 'last_n': 0, 'last_u': 0}

for i in stdin.readline().strip():
    if i in 'mw':
        print(0)
        exit(0)

    if i not in 'nu':
        dp = {
                'norm': (dp['norm'] + dp['last_n'] + dp['last_u']) % rem,
                'last_n': 0,
                'last_u': 0
        }
        continue

    if i == 'u':
        dp = {
                'norm': (dp['last_u'] + dp['last_n']) % rem,
                'last_u': (dp['last_u'] + dp['norm']) % rem,
                'last_n': 0
        }

    if i == 'n':
        dp = {
                'norm': (dp['last_n'] + dp['last_u']) % rem,
                'last_n': (dp['last_n'] + dp['norm']) % rem,
                'last_u': 0
        }
print((dp['norm'] + dp['last_u'] + dp['last_n']) % rem)


import sys
input=sys.stdin.readline

s=input()
n=len(s)-1
if s[0]=='m' or s[0]=='w' :
    print(0)
    exit
a=b=1

for i in range(1,n):
    if s[i]=='m' or s[i]=='w' :
        print(0)
        exit()
    if s[i]==s[i-1] and (s[i]=='u' or s[i]=='n' ) :
        c=a+b
        a,b=b,c
    else:
        a=b

print(b%(1000000000+7))


import sys
input=sys.stdin.readline

s=input()
n=len(s)-1
if s[0]=='m' or s[0]=='w' :
    print(0)
    exit()
a=b=1

for i in range(1,n):
    if s[i]=='m' or s[i]=='w' :
        print(0)
        exit()
    if s[i]==s[i-1] and (s[i]=='u' or s[i]=='n' ) :
        c=a+b
        a,b=b,c
    else:
        a=b

print(b%(1000000000+7))


s=input()
ans=1
t=0
pod=0
mas=[]
if s[0]=='n' or s[0]=='u':
    pod=1
if s[0]=='w' or s[0]=='m':
    print(0)
    exit()
for i in range(1,len(s)):
    if s[i]==s[i-1]=='u' or s[i]==s[i-1]=='n':
        pod+=1
    else:
        if pod!=0:
            mas.append(pod)
        pod=0
        if s[i] == 'n' or s[i] == 'u':
            pod = 1
    if s[i]=='m' or s[i]=='w':
        print(0)
        exit()
if pod!=0:
    mas.append(pod)
for i in range(len(mas)):
    if mas[i]!=1:
        b=mas[i]//2
        for j in range(b):
            ans=(ans*2)%(1000000007)
        if mas[i]%2==1:
            ans=(ans*2-1)%(1000000007)
print(ans)


s=input()
ans=1
t=0
pod=0
mas=[]
fib=[1,2]
for i in range(100000):
    fib.append((fib[len(fib)-1]+fib[len(fib)-2])%(1000000007))
if s[0]=='n' or s[0]=='u':
    pod=1
if s[0]=='w' or s[0]=='m':
    print(0)
    exit()
for i in range(1,len(s)):
    if s[i]==s[i-1]=='u' or s[i]==s[i-1]=='n':
        pod+=1
    else:
        if pod!=0:
            mas.append(pod)
        pod=0
        if s[i] == 'n' or s[i] == 'u':
            pod = 1
    if s[i]=='m' or s[i]=='w':
        print(0)
        exit()
if pod!=0:
    mas.append(pod)
for i in range(len(mas)):
    ans=(ans*fib[mas[i]-1])%(1000000007)
print(ans)


s=input()
ans=1
t=0
pod=0
mas=[]
if s[0]=='n' or s[0]=='u':
    pod=1
for i in range(1,len(s)):
    if s[i]==s[i-1]=='u' or s[i]==s[i-1]=='n':
        pod+=1
    else:
        if pod!=0:
            mas.append(pod)
        pod=0
        if s[i] == 'n' or s[i] == 'u':
            pod = 1
    if s[i]=='m' or s[i]=='w':
        print(0)
        exit()
if pod!=0:
    mas.append(pod)
for i in range(len(mas)):
    if mas[i]!=1:
        b=mas[i]//2
        for j in range(b):
            ans=(ans*2)%(1000000007)
        if mas[i]%2==1:
            ans=(ans*2-1)%(1000000007)
print(ans)


#n = int(input())
def can(x):
    val=sum(arr[n//2:])
    if x*(n//2+1)-val<=k:
        return True
    return False

#n,k=map(int, input().split())
#arr = list(map(int, input().split()))
s=input()
ans=1
cnt=1
f=[0]*(10**5+1)
f[1]=1
f[2]=2
f[3]=3
mod=10**9+7
for i in range(4,10**5+1):
    f[i]=f[i-1]+f[i-2]
    f[i]%=mod

for i in range(len(s)):
    if s[i]=="w" or s[i]=="m":
        print(0)
        exit()
    if i>0 and s[i]==s[i-1] and (s[i]=="u" or s[i]=="n"):
        cnt+=1
        if i==len(s)-1:
            ans*=f[cnt]
    else:
        ans*=f[cnt]
        ans%=mod
        cnt=1
print(ans%mod)


#n = int(input())
def can(x):
    val=sum(arr[n//2:])
    if x*(n//2+1)-val<=k:
        return True
    return False

#n,k=map(int, input().split())
#arr = list(map(int, input().split()))
s=input()
ans=1
cnt=1
f=[0]*(10**5+1)
f[1]=1
f[2]=2
f[3]=3
mod=10**9+7
for i in range(4,10**5+1):
    f[i]=f[i-1]+f[i-2]
    f[i]%=mod

for i in range(len(s)):
    if i>0 and s[i]==s[i-1] and (s[i]=="u" or s[i]=="n"):
        cnt+=1
        if i==len(s)-1:
            ans*=f[cnt]
    else:
        ans*=f[cnt]
        ans%=mod
        cnt=1
print(ans%mod)

#print(523833000*696657832*80612189*258079255)
#print(p)
#for _ in range(int(input())):
#l,r=map(int, input().split())


#n = int(input())
def can(x):
    val=sum(arr[n//2:])
    if x*(n//2+1)-val<=k:
        return True
    return False

#n,k=map(int, input().split())
#arr = list(map(int, input().split()))
s=input()
ans=1
cnt=1
f=[0]*(10**5+1)
f[1]=1
f[2]=2
f[3]=3
mod=10**9+7
for i in range(4,10**5+1):
    f[i]=f[i-1]+f[i-2]
for i in range(len(s)):
    if i>0 and s[i]==s[i-1] and (s[i]=="u" or s[i]=="n"):
        cnt+=1
        if i==len(s)-1:
            ans*=f[cnt]
    else:
        ans*=f[cnt]
        ans%=mod
        cnt=1
print(ans*mod)


#n = int(input())
def can(x):
    val=sum(arr[n//2:])
    if x*(n//2+1)-val<=k:
        return True
    return False

#n,k=map(int, input().split())
#arr = list(map(int, input().split()))
s=input()
ans=1
cnt=1
f=[0]*(10**5+1)
f[1]=1
f[2]=2
f[3]=3
mod=10**9+7
for i in range(4,10**5+1):
    f[i]=f[i-1]+f[i-2]
for i in range(len(s)):
    if i>0 and s[i]==s[i-1] and (s[i]=="u" or s[i]=="n"):
        cnt+=1
        if i==len(s)-1:
            ans*=f[cnt]

    else:

        ans*=f[cnt]
        ans%=mod

        cnt=1

print(ans*mod)


import math
import bisect
import sys
from collections import OrderedDict
input = sys.stdin.readline
def inp():
	return(int(input()))
def inlt():
	return(list(map(int,input().split())))
def insr():
	s = input()
	return(s[:len(s)-1])
def invr():
	return(map(int,input().split()))
# N, M = inlt()
# A = inlt()
# T = inp()
MOD = 1000000007
# print(MOD)
# for t in range(T):
S = insr()
N = len(S)
fl = True
for a in range(N):
	if S[a] == "m" or S[a] == "w":
		print(0)
		fl = False
		break
if fl:
	prev = -1
	i = 0
	out = 1
	L = [1]
	while i < N and S[i] != "n" and S[i] != "u":
		i += 1
	while i < N:
		if S[i] == "n":
			prev = i
			while i < N and S[i] == "n":
				i += 1
			# print(prev,i)
			curr = i-prev
			L.append(curr)
		if i < N and S[i] == "u":
			prev = i
			while i < N and S[i] == "u":
				i += 1
			# print(prev,i)
			curr = i-prev
			L.append(curr)
			i -= 1
		i += 1
	mm = max(2,max(L))
	dp = [0 for i in range(mm+1)]
	dp[1] = 1
	dp[2] = 2
	for j in range(3,mm+1):
		dp[j] = (dp[j-1]+dp[j-2])%MOD
	# print(dp)
	out = 1
	# print(MOD)
	for k in L:
		# print(dp[k])
		out = (out*dp[k])%MOD
		# print(out)
	print(out)


S = input()
N = len(S)
out = 1
mod = (10**9)+7
"""def f(num):
	if num%6 == 1:
		return 1
	elif num%6 == 2:
		return 2
	elif num%6 == 3:
		return 1
	elif num%6 == 4:
		return (10**9)+6
	elif num%6 == 5:
		return (10**9) +5
	else:
		return (10**9)+6"""
f = [0 for a in range(10**5)]
f[1] = 1
f[2] = 2
for b in range(3, (10**5)):
	f[b] = (f[b-1]+f[b-2])%mod
for i in range(N):
	if i < N and S[i] == "u":
		c = 1
		i += 1
		while i < N and S[i] == "u":
			c += 1
			i += 1
		out = (out*f[c])%mod
		if i == N:
			break
	if i < N and S[i] == "n":
		c = 1
		i += 1
		while i < N and S[i] == "n":
			c += 1
			i += 1
		out = (out*f[c])%mod
		if i == N:
			break
	if i < N and (S[i] == "m" or S[i] == "w"):
		out = 0
		break
print(out)


S = input()
N = len(S)
out = 1
mod = (10**9)+7
"""def f(num):
	if num%6 == 1:
		return 1
	elif num%6 == 2:
		return 2
	elif num%6 == 3:
		return 1
	elif num%6 == 4:
		return (10**9)+6
	elif num%6 == 5:
		return (10**9) +5
	else:
		return (10**9)+6"""
f = [0 for a in range(10**5)]
f[1] = 1
f[2] = 2
for b in range(3, (10**5)):
	f[b] = ((f[b-1]%mod)+(f[b-2]%mod))%mod
for i in range(N):
	if i < N and S[i] == "u":
		c = 1
		i += 1
		while i < N and S[i] == "u":
			c += 1
			i += 1
		out = ((out%mod)*(f[c]%mod))%mod
		if i == N:
			break
	if i < N and S[i] == "n":
		c = 1
		i += 1
		while i < N and S[i] == "n":
			c += 1
			i += 1
		out = ((out%mod)*(f[c]%mod))%mod
		if i == N:
			break
	if i < N and (S[i] == "m" or S[i] == "w"):
		out = 0
		break
print(out)


S = input()
N = len(S)
out = 1
mod = (10**9)+7
"""def f(num):
	if num%6 == 1:
		return 1
	elif num%6 == 2:
		return 2
	elif num%6 == 3:
		return 1
	elif num%6 == 4:
		return (10**9)+6
	elif num%6 == 5:
		return (10**9) +5
	else:
		return (10**9)+6"""
f = [0 for a in range(10**5)]
f[1] = 1
f[2] = 2
for b in range(3, (10**5)):
	f[b] = ((f[b-1]%mod)+(f[b-2]%mod))%mod
for i in range(N):
	if i < N and S[i] == "u":
		c = 1
		i += 1
		while i < N and S[i] == "u":
			c += 1
			i += 1
		out = ((out%mod)*f[c])%mod
		if i == N:
			break
	if i < N and S[i] == "n":
		c = 1
		i += 1
		while i < N and S[i] == "n":
			c += 1
			i += 1
		out = ((out%mod)*f[c])%mod
		if i == N:
			break
	if i < N and (S[i] == "m" or S[i] == "w"):
		out = 0
		break
print(out)


def f(n):
	global mod
	m = len(x)
	if m >= n: return x[n-1]
	for i in range(m-n): x.append((x[-1]+x[-2]))
	return x[-1]

s = input()
k = len(s)
x = [1,2,3,5,8]
ans = 1
i = 0
mod = 10**9 + 7
while i<k:
	t = s[i]
	if t == 'w' or t == 'm':
		ans = 0
		break
	elif t == 'u' or t == 'n':
		t1 = 1
		j = i+1
		while j < k:
			if s[j] == t: t1 += 1
			else: break
			j += 1
		ans = (ans*f(t1))
		i = j
	else: i+=1
print(ans%mod)


def f(n):
	global mod
	m = len(x)
	if m >= n: return x[n-1]
	for i in range(n-m): x.append((x[-1]+x[-2])%mod)
	return x[-1]

s = input()
k = len(s)
x = [1,2,3,5,8]
ans = 1
i = 0
mod = 10**9 + 7
while i<k:
	t = s[i]
	if t == 'w' or t == 'm':
		ans = 0
		break
	elif t == 'u' or t == 'n':
		t1 = 1
		j = i+1
		while j < k:
			if s[j] == t: t1 += 1
			else: break
			j += 1
		ans = (ans*f(t1))%mod
		i = j
	else: i+=1
print(ans)


def f(n):
	global mod
	m = len(x)
	if m >= n: return x[n-1]
	for i in range(m-n): x.append((x[-1]+x[-2])%mod)
	return x[-1]

s = input()
k = len(s)
x = [1,2,3,5,8]
ans = 1
i = 0
mod = 10**9 + 7
while i<k:
	t = s[i]
	if t == 'w' or t == 'm':
		ans = 0
		break
	elif t == 'u' or t == 'n':
		t1 = 1
		j = i+1
		while j < k:
			if s[j] == t: t1 += 1
			else: break
			j += 1
		ans = (ans*f(t1))%mod
		i = j
	else: i+=1
print(ans)


def solve(s):
    if 'm' in s or 'w' in s:
        return 0
    count = 1
    i = 0
    while i < len(s):
        if s[i] in 'nu':
            j = 0
            k = 0
            while j+i < len(s) and s[i+j] == s[i]:
                j += 1
                k += 1

            count *= fib(k)
            i += j+1
        else:
            i += 1
    return count

def fib(num):
    if num == 1:
        return 1
    a = 1
    b = 2
    for i in range(2, num):
        a, b = b, a+b
    return b

s = input()
print(solve(s)%(10**9+7))


def solve(s):
    if 'm' in s or 'w' in s:
        return 0
    count = 1
    i = 0
    while i < len(s):
        if s[i] in 'nu':
            j = 0
            k = 0
            while j+i < len(s) and s[i+j] == s[i]:
                j += 1
                k += 1

            count *= fib(k)
            i += j
        else:
            i += 1
    return count

def fib(num):
    if num == 1:
        return 1
    a = 1
    b = 2
    for i in range(2, num):
        a, b = b, a+b
    return b

s = input()
print(solve(s)%(10**9+7))


def solve(s):
    if 'm' in s or 'w' in s:
        return 0
    count = 1
    i = 0
    while i < len(s):
        if s[i] in 'nu':
            j = 0
            k = 0
            while j+i < len(s) and s[i+j] == s[i]:
                j += 1
                k += 1

            count *= fib(k)
            i += j+1
        else:
            i += 1
    return count

def fib(num):
    if num == 1:
        return 1
    a = 1
    b = 2
    for i in range(2, num):
        a, b = b, a+b
    return b

s = input()
print(solve(s))


def solve(s):
    if 'm' in s or 'w' in s:
        return 0
    count = 1
    i = 0
    while i < len(s):
        if s[i] in 'nu':
            j = 0
            k = 0
            while j+i < len(s) and s[i+j] == s[i]:
                j += 1
                k += 1

            count *= fib(k)
            i += j+1
        else:
            i += 1
    return count

def fib(num):
    if num == 1:
        return 1
    a = 1
    b = 2
    for i in range(2, num):
        a, b = b, a+b
    return b

s = input()
print(solve(s)%(10**9+7)


fib=[1]*100005
fib[1]=2
for i in range(2,len(fib)):
	fib[i]=fib[i-1]+fib[i-2]

s=input()
if "m" in s or "w" in s:
	print (0)
	exit()
else:
	ans=[]
	curr="n"
	count=1
	for i in range(1,len(s)):
		if s[i]==curr:
			count+=1
		else:
			if curr=="u" or curr=="n":
				ans.append(count)
			if s[i]=="u":
				count=1
				curr="u"
			elif s[i]=="n":
				count=1
				curr="n"
			else:
				curr=""
	if curr=="u" or curr=="n":
		ans.append(count)
#print (ans)
count=1
for i in ans:
	count=(count*(fib[i-1]))%1000000007
print (count)


fib=[1]*100005
fib[1]=2
for i in range(2,len(fib)):
	fib[i]=(fib[i-1]+fib[i-2])%1000000007

s=input()
if "m" in s or "w" in s:
	print (0)
	exit()
else:
	ans=[]
	curr=s[0]
	if curr=="u"  or curr=="n":
		count=1
	else:
		count=0
	for i in range(1,len(s)):
		if s[i]==curr:
			count+=1
		else:
			if curr=="u" or curr=="n":
				ans.append(count)
			if s[i]=="u":
				count=1
				curr="u"
			elif s[i]=="n":
				count=1
				curr="n"
			else:
				curr=""
				count=0
	if curr=="u" or curr=="n":
		ans.append(count)
#print (ans)
count=1
for i in ans:
	count=(count*(fib[i-1]))%1000000007
print (count)


fib=[1]*100005
fib[1]=2
for i in range(2,len(fib)):
	fib[i]=(fib[i-1]+fib[i-2])%1000000007

s=input()
if "m" in s or "w" in s:
	print (0)
	exit()
else:
	ans=[]
	curr="n"
	count=1
	for i in range(1,len(s)):
		if s[i]==curr:
			count+=1
		else:
			if curr=="u" or curr=="n":
				ans.append(count)
			if s[i]=="u":
				count=1
				curr="u"
			elif s[i]=="n":
				count=1
				curr="n"
			else:
				curr=""
	if curr=="u" or curr=="n":
		ans.append(count)
#print (ans)
count=1
for i in ans:
	count=(count*(fib[i-1]))%1000000007
print (count)


s=input()
if "m" in s or "w" in s:
	print (0)
else:
	count1=0
	count2=0
	for i in range(len(s)-1):
		if s[i]=="u" and s[i+1]=="u":
			count1+=1
		elif s[i]=="n" and s[i+1]=="n":
			count2+=1
	print (((count1+1)*(count2+1))%1000000007)


class Constanze:
    def __init__(self):
        self.cache = {1: 1, 2: 2}

    def determine_value(self, n: int):
        max_stored_in_cache = len(self.cache)
        if n > max_stored_in_cache:
            for i in range(max_stored_in_cache + 1, n + 1):
                self.cache[i] = self.cache[i - 1] + self.cache[i - 2]
        return self.cache[n]

def constanze(s: str) -> int:
    for c in s:
        if c == 'm' or c == 'w':
            return 0
    import re
    sequence_that_matters = re.findall(r'[n]+|[u]+', s)
    possible_strings = 1
    constanze = Constanze()
    for sequence in sequence_that_matters:
        possible_strings *= constanze.determine_value(len(sequence))
    return possible_strings % 1000000007

def test():
    assert constanze("ouuokarinn") == 4
    assert constanze("banana") == 1
    assert constanze("nnn") == 3
    assert constanze("amanda") == 0
    assert constanze("nnnnnn") == 13

if __name__ == '__main__':
    s = input()
    print(constanze(s))


class Constanze:
    def __init__(self):
        self.cache = {1: 1, 2: 2}

    def determine_value(self, n: int):
        max_stored_in_cache = len(self.cache)
        if n > max_stored_in_cache:
            for i in range(max_stored_in_cache + 1, n + 1):
                self.cache[i] = self.cache[i - 1] + self.cache[i - 2]
        return self.cache[n]

def constanze(s: str) -> int:
    if 'm' in s or 'w' in s:
        return 0
    elif len(s) <= 1:
        return 1
    dp1, dp2 = 1, 1
    for i in range(1, len(s)):
        if s[i - 1] == s[i] and (s[i] == 'n' or s[i] == 'u'):
            t = dp1
            dp1 = dp1 + dp2
            dp2 = t
        else:
            dp2 = dp1
    return dp1 % 1000000007

def test():
    assert constanze("ouuokarinn") == 4
    assert constanze("banana") == 1
    assert constanze("nnn") == 3
    assert constanze("amanda") == 0
    assert constanze("a") == 1
    assert constanze("uuunnnuuunnn") == 81

if __name__ == '__main__':
    s = input()
    print(constanze(s))


class Constanze:
    def __init__(self):
        self.cache = {1: 1, 2: 2}

    def determine_value(self, n: int):
        max_stored_in_cache = len(self.cache)
        if n > max_stored_in_cache:
            for i in range(max_stored_in_cache + 1, n + 1):
                self.cache[i] = self.cache[i - 1] + self.cache[i - 2]
        return self.cache[n]

def constanze(s: str) -> int:
    if s[0] == 'm' or s[0] == 'w':
        return 0
    constanze = Constanze()
    prev_char = s[0]
    consecutive_char = 1
    possible_strings = 1
    for i in range(1, len(s)):
        c = s[i]
        if c == 'm' or c == 'w':
            return 0
        if c == prev_char:
            consecutive_char += 1
        if i == len(s) - 1 or (c != prev_char and consecutive_char >= 2):
            constanze_value = constanze.determine_value(consecutive_char)
            possible_strings *= constanze_value
            consecutive_char = 1
        prev_char = c
    return possible_strings % 1000000007

def test():
    assert constanze("ouuokarinn") == 4
    assert constanze("banana") == 1
    assert constanze("nnn") == 3
    assert constanze("amanda") == 0
    assert constanze("nnnnnn") == 13

if __name__ == '__main__':
    s = input()
    print(constanze(s))


class Constanze:
    def __init__(self):
        self.cache = {1: 1, 2: 2}

    def determine_value(self, n: int):
        if n not in self.cache:
            self.cache[n] = self.determine_value(n - 1) + self.determine_value(n - 2)
        return self.cache[n]

def constanze(s: str) -> int:
    constanze = Constanze()
    prev_char = s[0]
    consecutive_char = 1
    possible_strings = 1
    for i in range(1, len(s)):
        c = s[i]
        if c == 'm' or c == 'w':
            return 0
        if c == prev_char:
            consecutive_char += 1
        if i == len(s) - 1 or (c != prev_char and consecutive_char >= 2):
            constanze_value = constanze.determine_value(consecutive_char)
            possible_strings *= constanze_value
            consecutive_char = 1
        prev_char = c
        if possible_strings > 1000000007:
            possible_strings = possible_strings % 1000000007
    return possible_strings

def test():
    assert constanze("ouuokarinn") == 4
    assert constanze("banana") == 1
    assert constanze("nnn") == 3
    assert constanze("amanda") == 0

if __name__ == '__main__':
    s = input()
    print(constanze(s))


class Constanze:
    def __init__(self):
        self.cache = {1: 1, 2: 2}

    def determine_value(self, n: int):
        max_stored_in_cache = len(self.cache)
        if n > max_stored_in_cache:
            for i in range(max_stored_in_cache + 1, n + 1):
                self.cache[i] = self.cache[i - 1] + self.cache[i - 2]
        return self.cache[n]

def constanze(s: str) -> int:
    if s[0] == 'm' or s[0] == 'w':
        return 0
    constanze = Constanze()
    prev_char = s[0]
    consecutive_char = 1
    possible_strings = 1
    for i in range(1, len(s)):
        c = s[i]
        if c == 'm' or c == 'w':
            return 0
        if c == prev_char:
            consecutive_char += 1
        if i == len(s) - 1 or (c != prev_char and consecutive_char >= 2):
            constanze_value = constanze.determine_value(consecutive_char)
            possible_strings *= constanze_value
            consecutive_char = 1
        prev_char = c
        if possible_strings > 1000000007:
            possible_strings = possible_strings % 1000000007
    return possible_strings

def test():
    # assert constanze("ouuokarinn") == 4
    # assert constanze("banana") == 1
    # assert constanze("nnn") == 3
    # assert constanze("amanda") == 0
    assert constanze("nnnnnn") == 13

if __name__ == '__main__':
    s = input()
    print(constanze(s))


class Constanze:
    def __init__(self):
        self.cache = {1: 1, 2: 2}

    def determine_value(self, n: int):
        if n not in self.cache:
            self.cache[n] = self.determine_value(n - 1) + self.determine_value(n - 2)
        return self.cache[n]

def constanze(s: str) -> int:
    if s[0] == 'm' or s[0] == 'w':
        return 0
    constanze = Constanze()
    prev_char = s[0]
    consecutive_char = 1
    possible_strings = 1
    for i in range(1, len(s)):
        c = s[i]
        if c == 'm' or c == 'w':
            return 0
        if c == prev_char:
            consecutive_char += 1
        if i == len(s) - 1 or (c != prev_char and consecutive_char >= 2):
            constanze_value = constanze.determine_value(consecutive_char)
            possible_strings *= constanze_value
            consecutive_char = 1
        prev_char = c
        if possible_strings > 1000000007:
            possible_strings = possible_strings % 1000000007
    return possible_strings

def test():
    assert constanze("ouuokarinn") == 4
    assert constanze("banana") == 1
    assert constanze("nnn") == 3
    assert constanze("amanda") == 0

if __name__ == '__main__':
    s = input()
    print(constanze(s))