Start: Jan, 04, 2017 19:40:00
2016年秋季学期程序设计基础期末考试
End: Jan, 04, 2017 21:40:00
Time elapsed:
Time remaining:

Problem_ID: G
Result: Accepted
Time: 216ms
Memory: 1700kB
Author: SuperBlade
In contest: 1084

#include<cstdio>
#include <string>
#include <string.h>
#include <cmath>
#include<stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdlib>
#include <iostream>
#include<algorithm>
using namespace std;
typedef long long ll;


ll gcd(ll x, ll y)
{
	return y == 0? x:gcd(y, x%y);	
}

ll lcm(ll x, ll y)
{
	return x/gcd(x,y)*y;
}

ll pow_mod(ll a,ll n, ll mod)
{
	ll res=1;
	while(n)
	{
		if(n&1)res= res*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return res;
}

/*
input:1 0.0001
output:0.36788
*/
double fun(double x[10])
{
	int i;
	long t;
	double avg=0,sum=0;
	for(int i =0 ;i < 10;i++)
	{
		sum+=x[i];
	}

	avg=sum*100;
	t=avg;
	avg=(double)t/100;
	return avg;
}


struct node 
{

	string name;
	int a,b;
};
bool com(const node &x,const node &y)
{
	return x.a+x.b>y.a+y.b;
}

typedef unsigned long long ull;



int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		char a[102][102];
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=0;i<n;i++)scanf("%s",a+i);
		for(int i=0;i<n;i++)for(int j=0;j<m;j++)a[i][j]-='a';
		int q;
		scanf("%d",&q);
		for(int i =0 ;i<q;i++)
		{

			int x,y,z;
			scanf("%d%d%d",&x,&y,&z);
			//printf("%c",a[x][y]);
			a[x][y]+=z;
			while(a[x][y]>=26)a[x][y]-=26;
			while(a[x][y]<0)a[x][y]+=26;
			//printf("%c",a[x][y]);
		}
		for(int i=0;i<n;i++)for(int j=0;j<m;j++)a[i][j]+='a';
		for(int i=0;i<n;i++)printf("%s\n",a[i]);
	}
}