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

#define sd(x) 		scanf("%d",&x)
#define su(x) 		scanf("%u",&x)
#define slld(x) 	scanf("%lld",&x)
#define sc(x) 		scanf("%c",&x)
#define ss(x) 		scanf("%s",x)
#define sf(x) 		scanf("%f",&x)
#define slf(x)		scanf("%lf",&x)
#define ll 			long long int
#define mod(x,n) 	(x+n)%n
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
ll mod = 1000000007;

char G[1007][1007];
ll LTR[1007][1007];
ll RTL[1007][1007];
ll TTB[1007][1007];
ll BTT[1007][1007];
bool included[1007][1007];
vector<pair<ll, ll> > segment[1007];

vector<pair<pair<int, int>, int> > answer;

int main()
{
	// freopen("input_file_name.in","r",stdin);
	// freopen("output_file_name.out","w",stdout);

	// int i,j,k,l,m,n,x,y,z,a,b,r;
	ll i,j,k,l,m,n,p,q,x,y,z,a,b,r,s,fs,ls,md;

	slld(n);	slld(m);

	for(i=1;i<=n;i++)
		ss(G[i]+1);

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(G[i][j-1]=='*' && G[i][j]=='*')
				LTR[i][j] = LTR[i][j-1] + 1;

	for(i=1;i<=n;i++)
		for(j=m;j>=1;j--)
			if(G[i][j+1]=='*' && G[i][j]=='*')
				RTL[i][j] = RTL[i][j+1] + 1;

	for(j=1;j<=m;j++)
		for(i=1;i<=n;i++)
			if(G[i-1][j]=='*' && G[i][j]=='*')
				TTB[i][j] = TTB[i-1][j] + 1;

	for(j=1;j<=m;j++)
		for(i=n;i>=1;i--)
			if(G[i+1][j]=='*' && G[i][j]=='*')
				BTT[i][j] = BTT[i+1][j] + 1;

	// for(i=1;i<=n;i++)
	// {
	// 	for(j=1;j<=m;j++)
	// 	{
	// 		printf("%lld ", LTR[i][j]);
	// 	}
	// 	printf("\n");
	// }

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(i+1<=n && i-1>=1 && j+1<=m && j-1>=1 && G[i][j]=='*' && G[i+1][j]=='*' && G[i-1][j]=='*' && G[i][j+1]=='*' && G[i][j-1]=='*')
			{
				k = min(LTR[i][j], min(RTL[i][j], min(TTB[i][j], BTT[i][j])));
				answer.pb(mp(mp(i, j), k));
			}

	bool is_possible = true;

	for(i=0;i<sz(answer);i++)
	{
		segment[answer[i].F.S].pb(mp((answer[i].F.F) - (answer[i].S), (answer[i].F.F) + (answer[i].S)));
	}
	for(j=1;j<=m;j++)
	{
		sort(segment[j].begin(), segment[j].end());
	}
	for(j=1;j<=m;j++)
	{
		// printf("%lld : \n", j);
		i = 0;
		for(k=0;k<sz(segment[j]);k++)
		{
			// printf("-> %lld %lld\n", segment[j][k].F, segment[j][k].S);
			i = max(i, segment[j][k].F);
			while(i<=segment[j][k].S)
			{
				included[i][j] = true;
				i++;
			}
		}
	}

	for(j=1;j<=m;j++)
		segment[j].clear();

	for(i=0;i<sz(answer);i++)
	{
		segment[answer[i].F.F].pb(mp((answer[i].F.S) - (answer[i].S), (answer[i].F.S) + (answer[i].S)));
	}
	for(i=1;i<=n;i++)
	{
		sort(segment[i].begin(), segment[i].end());
	}
	for(i=1;i<=n;i++)
	{
		// printf("%lld : \n", i);
		j = 0;
		for(k=0;k<sz(segment[i]);k++)
		{
			// printf("-> %lld %lld\n", segment[i][k].F, segment[i][k].S);
			j = max(j, segment[i][k].F);
			while(j<=segment[i][k].S)
			{
				included[i][j] = true;
				j++;
			}
		}
	}

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(!included[i][j] && G[i][j]=='*')
				is_possible = false;

	if(!is_possible)
	{
		printf("-1\n");
	}
	else
	{
		printf("%d\n", sz(answer));
		for(i=0;i<sz(answer);i++)
		{
			printf("%d %d %d\n", answer[i].F.F, answer[i].F.S, answer[i].S);
		}
	}

	return 0;
}


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

#define sd(x) 		scanf("%d",&x)
#define su(x) 		scanf("%u",&x)
#define slld(x) 	scanf("%lld",&x)
#define sc(x) 		scanf("%c",&x)
#define ss(x) 		scanf("%s",x)
#define sf(x) 		scanf("%f",&x)
#define slf(x)		scanf("%lf",&x)
#define ll 			long long int
#define mod(x,n) 	(x+n)%n
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
ll mod = 1000000007;

char G[107][107];
bool included[107][107];

vector<pair<pair<int, int>, int> > answer;

int main()
{
	// freopen("input_file_name.in","r",stdin);
	// freopen("output_file_name.out","w",stdout);

	// int i,j,k,l,m,n,x,y,z,a,b,r;
	ll i,j,k,l,m,n,p,q,x,y,z,a,b,r,s;

	slld(n);	slld(m);

	for(i=0;i<n;i++)
		ss(G[i]);

	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(G[i][j]=='*')
			{
				k = 1;
				while(i+k<n && i-k>=0 && j+k<m && j-k>=0 && G[i+k][j]=='*' && G[i][j+k]=='*' && G[i-k][j]=='*' && G[i][j-k]=='*')
				{
					included[i][j] = included[i+k][j] = included[i][j+k] = included[i-k][j] = included[i][j-k] = true;
					k++;
				}
				if(k-1>=1)
					answer.pb(mp(mp(i+1, j+1), k-1));
			}
		}
	}

	bool is_possible = true;

	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(G[i][j]=='*' && included[i][j]==false)
				is_possible = false;
		}
	}

	if(!is_possible)
	{
		printf("-1\n");
	}
	else
	{
		printf("%d\n", sz(answer));
		for(i=0;i<sz(answer);i++)
		{
			printf("%d %d %d\n", answer[i].F.F, answer[i].F.S, answer[i].S);
		}
	}

	return 0;
}


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

#define sd(x) 		scanf("%d",&x)
#define su(x) 		scanf("%u",&x)
#define slld(x) 	scanf("%lld",&x)
#define sc(x) 		scanf("%c",&x)
#define ss(x) 		scanf("%s",x)
#define sf(x) 		scanf("%f",&x)
#define slf(x)		scanf("%lf",&x)
#define ll 			long long int
#define mod(x,n) 	(x+n)%n
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
ll mod = 1000000007;

char G[107][107];
ll LTR[107][107];
ll TTB[107][107];
bool included[107][107];
vector<pair<ll, ll> > segment[107];

vector<pair<pair<int, int>, int> > answer;

bool check(ll i, ll j, ll k, ll n, ll m)
{
	if(i+k<=n && j+k<=m && j-k>=1 && i-k>=1 && LTR[i][j+k]-LTR[i][j-k-1]==2*k+1 && TTB[i+k][j]-TTB[i-k-1][j]==2*k+1)
		return true;
	return false;
}

int main()
{
	// freopen("input_file_name.in","r",stdin);
	// freopen("output_file_name.out","w",stdout);

	// int i,j,k,l,m,n,x,y,z,a,b,r;
	ll i,j,k,l,m,n,p,q,x,y,z,a,b,r,s,fs,ls,md;

	slld(n);	slld(m);

	for(i=1;i<=n;i++)
		ss(G[i]+1);

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(G[i][j]=='*')
				LTR[i][j] = TTB[i][j] = 1;

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			LTR[i][j] = LTR[i][j] + LTR[i][j-1];

	for(j=1;j<=m;j++)
		for(i=1;i<=n;i++)
			TTB[i][j] = TTB[i][j] + TTB[i-1][j];

	// for(i=1;i<=n;i++)
	// {
	// 	for(j=1;j<=m;j++)
	// 	{
	// 		printf("%lld ", LTR[i][j]);
	// 	}
	// 	printf("\n");
	// }

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(i+1<=n && i-1>=1 && j+1<=m && j-1>=1 && G[i][j]=='*' && G[i+1][j]=='*' && G[i-1][j]=='*' && G[i][j+1]=='*' && G[i][j-1]=='*')
			{
				fs = 1;	ls = max(n, m) + 1;
				while(fs+1<ls)
				{
					md = (fs+ls)/2;
					if(check(i, j, md, n, m))
						fs = md;
					else
						ls = md;
				}
				answer.pb(mp(mp(i, j), fs));
			}

	bool is_possible = true;

	for(i=0;i<sz(answer);i++)
	{
		segment[answer[i].F.S].pb(mp((answer[i].F.F) - (answer[i].S), (answer[i].F.F) + (answer[i].S)));
	}
	for(j=1;j<=m;j++)
	{
		sort(segment[j].begin(), segment[j].end());
	}
	for(j=1;j<=m;j++)
	{
		// printf("%lld : \n", j);
		i = 0;
		for(k=0;k<sz(segment[j]);k++)
		{
			// printf("-> %lld %lld\n", segment[j][k].F, segment[j][k].S);
			i = max(i, segment[j][k].F);
			while(i<=segment[j][k].S)
			{
				included[i][j] = true;
				i++;
			}
		}
	}

	for(j=1;j<=m;j++)
		segment[j].clear();

	for(i=0;i<sz(answer);i++)
	{
		segment[answer[i].F.F].pb(mp((answer[i].F.S) - (answer[i].S), (answer[i].F.S) + (answer[i].S)));
	}
	for(i=1;i<=n;i++)
	{
		sort(segment[i].begin(), segment[i].end());
	}
	for(i=1;i<=n;i++)
	{
		// printf("%lld : \n", i);
		j = 0;
		for(k=0;k<sz(segment[i]);k++)
		{
			// printf("-> %lld %lld\n", segment[i][k].F, segment[i][k].S);
			j = max(j, segment[i][k].F);
			while(j<=segment[i][k].S)
			{
				included[i][j] = true;
				j++;
			}
		}
	}

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(!included[i][j] && G[i][j]=='*')
				is_possible = false;

	if(!is_possible)
	{
		printf("-1\n");
	}
	else
	{
		printf("%d\n", sz(answer));
		for(i=0;i<sz(answer);i++)
		{
			printf("%d %d %d\n", answer[i].F.F, answer[i].F.S, answer[i].S);
		}
	}

	return 0;
}


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

#define sd(x) 		scanf("%d",&x)
#define su(x) 		scanf("%u",&x)
#define slld(x) 	scanf("%lld",&x)
#define sc(x) 		scanf("%c",&x)
#define ss(x) 		scanf("%s",x)
#define sf(x) 		scanf("%f",&x)
#define slf(x)		scanf("%lf",&x)
#define ll 			long long int
#define mod(x,n) 	(x+n)%n
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
ll mod = 1000000007;

char G[1007][1007];
ll LTR[1007][1007];
ll TTB[1007][1007];
bool included[1007][1007];
vector<pair<ll, ll> > segment[1007];

vector<pair<pair<int, int>, int> > answer;

bool check(ll i, ll j, ll k, ll n, ll m)
{
	if(i+k<=n && j+k<=m && j-k>=1 && i-k>=1 && LTR[i][j+k]-LTR[i][j-k-1]==2*k+1 && TTB[i+k][j]-TTB[i-k-1][j]==2*k+1)
		return true;
	return false;
}

int main()
{
	// freopen("input_file_name.in","r",stdin);
	// freopen("output_file_name.out","w",stdout);

	// int i,j,k,l,m,n,x,y,z,a,b,r;
	ll i,j,k,l,m,n,p,q,x,y,z,a,b,r,s,fs,ls,md;

	slld(n);	slld(m);

	for(i=1;i<=n;i++)
		ss(G[i]+1);

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(G[i][j]=='*')
				LTR[i][j] = TTB[i][j] = 1;

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			LTR[i][j] = LTR[i][j] + LTR[i][j-1];

	for(j=1;j<=m;j++)
		for(i=1;i<=n;i++)
			TTB[i][j] = TTB[i][j] + TTB[i-1][j];

	// for(i=1;i<=n;i++)
	// {
	// 	for(j=1;j<=m;j++)
	// 	{
	// 		printf("%lld ", LTR[i][j]);
	// 	}
	// 	printf("\n");
	// }

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(i+1<=n && i-1>=1 && j+1<=m && j-1>=1 && G[i][j]=='*' && G[i+1][j]=='*' && G[i-1][j]=='*' && G[i][j+1]=='*' && G[i][j-1]=='*')
			{
				fs = 1;	ls = max(n, m) + 1;
				while(fs+1<ls)
				{
					md = (fs+ls)/2;
					if(check(i, j, md, n, m))
						fs = md;
					else
						ls = md;
				}
				answer.pb(mp(mp(i, j), fs));
			}

	bool is_possible = true;

	for(i=0;i<sz(answer);i++)
	{
		segment[answer[i].F.S].pb(mp((answer[i].F.F) - (answer[i].S), (answer[i].F.F) + (answer[i].S)));
	}
	for(j=1;j<=m;j++)
	{
		sort(segment[j].begin(), segment[j].end());
	}
	for(j=1;j<=m;j++)
	{
		// printf("%lld : \n", j);
		i = 0;
		for(k=0;k<sz(segment[j]);k++)
		{
			// printf("-> %lld %lld\n", segment[j][k].F, segment[j][k].S);
			i = max(i, segment[j][k].F);
			while(i<=segment[j][k].S)
			{
				included[i][j] = true;
				i++;
			}
		}
	}

	for(j=1;j<=m;j++)
		segment[j].clear();

	for(i=0;i<sz(answer);i++)
	{
		segment[answer[i].F.F].pb(mp((answer[i].F.S) - (answer[i].S), (answer[i].F.S) + (answer[i].S)));
	}
	for(i=1;i<=n;i++)
	{
		sort(segment[i].begin(), segment[i].end());
	}
	for(i=1;i<=n;i++)
	{
		// printf("%lld : \n", i);
		j = 0;
		for(k=0;k<sz(segment[i]);k++)
		{
			// printf("-> %lld %lld\n", segment[i][k].F, segment[i][k].S);
			j = max(j, segment[i][k].F);
			while(j<=segment[i][k].S)
			{
				included[i][j] = true;
				j++;
			}
		}
	}

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(!included[i][j] && G[i][j]=='*')
				is_possible = false;

	if(!is_possible)
	{
		printf("-1\n");
	}
	else
	{
		printf("%d\n", sz(answer));
		for(i=0;i<sz(answer);i++)
		{
			printf("%d %d %d\n", answer[i].F.F, answer[i].F.S, answer[i].S);
		}
	}

	return 0;
}


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

#define sd(x) 		scanf("%d",&x)
#define su(x) 		scanf("%u",&x)
#define slld(x) 	scanf("%lld",&x)
#define sc(x) 		scanf("%c",&x)
#define ss(x) 		scanf("%s",x)
#define sf(x) 		scanf("%f",&x)
#define slf(x)		scanf("%lf",&x)
#define ll 			long long int
#define mod(x,n) 	(x+n)%n
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
ll mod = 1000000007;

char G[107][107];
int LTR[107][107];
int TTB[107][107];
bool included[107][107];

vector<pair<pair<int, int>, int> > answer;

bool check(ll i, ll j, ll k, ll n, ll m)
{
	if(!(i+k<=n && j+k<=m && j-k>=1 && i-k>=1))
		return false;
	if(LTR[i][j+k]-LTR[i][j]==k && LTR[i][j-1]-LTR[i][j-k-1]==k && TTB[i+k][j]-TTB[i][j]==k && TTB[i-1][j]-TTB[i-k-1][j]==k)
		return true;
	return false;
}

int main()
{
	// freopen("input_file_name.in","r",stdin);
	// freopen("output_file_name.out","w",stdout);

	// int i,j,k,l,m,n,x,y,z,a,b,r;
	ll i,j,k,l,m,n,p,q,x,y,z,a,b,r,s,ls,ls,md;

	slld(n);	slld(m);

	for(i=1;i<=n;i++)
		ss(G[i]+1);

	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(G[i][j]=='*')
				LTR[i][j] = TTB[i][j] = 1;

	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			LTR[i][j] = LTR[i][j] + LTR[i][j-1];

	for(j=1;j<=m;j++)
		for(i=1;i<=n;i++)
			TTB[i][j] = TTB[i][j] + TTB[i-1][j];

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(i+1<=n && i-1>=1 && j+1<=m && j-1>=1 && G[i][j]=='*' && G[i+1][j]=='*' && G[i-1][j]=='*' && G[i][j+1]=='*' && G[i][j-1]=='*')
			{
				fs = 1;	ls = max(n, m);
				while(fs+1<ls)
				{
					md = (fs+ls)/2;
					if(check(i, j, md, n, m))
						fs = md;
					else
						ls = md;
				}
				if(check(i, j, ls, n, m))
					k = ls;
				else
					k = fs;
				answer.pb(mp(mp(i, j), k));
			}

	bool is_possible = true;

	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(G[i][j]=='*' && included[i][j]==false)
				is_possible = false;
		}
	}

	if(!is_possible)
	{
		printf("-1\n");
	}
	else
	{
		printf("%d\n", sz(answer));
		for(i=0;i<sz(answer);i++)
		{
			printf("%d %d %d\n", answer[i].F.F, answer[i].F.S, answer[i].S);
		}
	}

	return 0;
}


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

#define sd(x) 		scanf("%d",&x)
#define su(x) 		scanf("%u",&x)
#define slld(x) 	scanf("%lld",&x)
#define sc(x) 		scanf("%c",&x)
#define ss(x) 		scanf("%s",x)
#define sf(x) 		scanf("%f",&x)
#define slf(x)		scanf("%lf",&x)
#define ll 			long long int
#define mod(x,n) 	(x+n)%n
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
ll mod = 1000000007;

char G[107][107];
int LTR[107][107];
int TTB[107][107];
bool included[107][107];

vector<pair<pair<int, int>, int> > answer;

bool check(ll i, ll j, ll k, ll n, ll m)
{
	if(!(i+k<=n && j+k<=m && j-k>=1 && i-k>=1))
		return false;
	if(LTR[i][j+k]-LTR[i][j]==k && LTR[i][j-1]-LTR[i][j-k-1]==k && TTB[i+k][j]-TTB[i][j]==k && TTB[i-1][j]-TTB[i-k-1][j]==k)
		return true;
	return false;
}

int main()
{
	// freopen("input_file_name.in","r",stdin);
	// freopen("output_file_name.out","w",stdout);

	// int i,j,k,l,m,n,x,y,z,a,b,r;
	ll i,j,k,l,m,n,p,q,x,y,z,a,b,r,s,fs,ls,md;

	slld(n);	slld(m);

	for(i=1;i<=n;i++)
		ss(G[i]+1);

	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(G[i][j]=='*')
				LTR[i][j] = TTB[i][j] = 1;

	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			LTR[i][j] = LTR[i][j] + LTR[i][j-1];

	for(j=1;j<=m;j++)
		for(i=1;i<=n;i++)
			TTB[i][j] = TTB[i][j] + TTB[i-1][j];

	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(i+1<=n && i-1>=1 && j+1<=m && j-1>=1 && G[i][j]=='*' && G[i+1][j]=='*' && G[i-1][j]=='*' && G[i][j+1]=='*' && G[i][j-1]=='*')
			{
				fs = 1;	ls = max(n, m);
				while(fs+1<ls)
				{
					md = (fs+ls)/2;
					if(check(i, j, md, n, m))
						fs = md;
					else
						ls = md;
				}
				if(check(i, j, ls, n, m))
					k = ls;
				else
					k = fs;
				answer.pb(mp(mp(i, j), k));
			}

	bool is_possible = true;

	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			if(G[i][j]=='*' && included[i][j]==false)
				is_possible = false;
		}
	}

	if(!is_possible)
	{
		printf("-1\n");
	}
	else
	{
		printf("%d\n", sz(answer));
		for(i=0;i<sz(answer);i++)
		{
			printf("%d %d %d\n", answer[i].F.F, answer[i].F.S, answer[i].S);
		}
	}

	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
string cks[N];
int partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				cks[i][j] = '*';
				cnt++;
			}
		}
	}
	return cnt;
}
int main() {
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[1005];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		scanf("%d %d", &n, &m);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = r[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i][j] == '.') {
					cks[i][j] = '.';
				}
			}
		}
		partial_sum(); int ck = 1;
		for (int i = 0; i < n; i++) {
			if (cks[i] != s[i]) {
				ck = 0;
				break;
			}
		}
		//cout << ck << endl;
		if (ck == 1) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				cout << vt[i].ss.ff + 1 << " " << vt[i].ss.ss + 1 << " " << vt[i].ff << endl;
			}
		}
		else {
			cout << -1 << endl;
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
//string cks[N],assign;
int partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				//cks[i][j] = '*';
				cnt++;
			}
		}
	} return cnt;

}
int main() {
	cin.tie(NULL);
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[1005];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		scanf("%d %d", &n, &m);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = l[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i][j] == '.')cnt++;
			}

		}
		cnt = partial_sum();
		int ck = 1;

		//cout << ck << endl;

		if (cnt == n * m) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				cout << vt[i].ss.ff + 1 << " " << vt[i].ss.ss + 1 << " " << vt[i].ff << endl;
			}
		}
		else {
			cout << -1 << endl;
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
//string cks[N],assign;
int partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				//cks[i][j] = '*';
				cnt++;
			}
		}
	} return cnt;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[N];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		scanf("%d %d", &n, &m);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = l[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i][j] == '.')cnt++;
			}

		}
		cnt = partial_sum();
		int ck = 1;

		//cout << ck << endl;

		if (cnt == n * m) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				//printf("%d %d %d\n", vt[i].ss.ff + 1, vt[i].ss.ss + 1, vt[i].ff );
				cout << vt[i].ss.ff + 1 << " " << vt[i].ss.ss + 1 << " " << vt[i].ff << endl;
			}
		}
		else {
			//printf("-1\n");
			cout << -1 << endl;
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
string ck[N];
int partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				//ck[i][j]
				cnt++;
			}
		}
	}
	return cnt;
}
int main() {
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[1005];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		scanf("%d %d", &n, &m);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = r[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i][j] == '.') {
					cnt++;
				}
			}
		}
		int ck = partial_sum();
		//cout << ck << endl;
		if (ck == n * m) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				cout << vt[i].ss.ff+1 << " " << vt[i].ss.ss+1 << " " << vt[i].ff << endl;
			}
		}
		else {
			cout << -1 << endl;
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
//string cks[N],assign;
int partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				//cks[i][j] = '*';
				cnt++;
			}
		}
	} return cnt;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[N];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		//scanf("%d %d", &n, &m);
		cin>>n>>m;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = l[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i][j] == '.')cnt++;
			}

		}
		cnt = partial_sum();
		int ck = 1;

		//cout << ck << endl;

		if (cnt == n * m) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				//printf("%d %d %d\n", vt[i].ss.ff + 1, vt[i].ss.ss + 1, vt[i].ff );
				cout <<vt[i].ss.ff + 1 << " " << vt[i].ss.ss + 1 << " " << vt[i].ff << endl;
			}
		}
		else {
			//printf("-1\n");
			cout << -1 << endl;
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
string cks[N],assign;
void partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				cks[i][j] = '*';

			}
		}
	}

}
int main() {
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[1005];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		scanf("%d %d", &n, &m);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = l[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				assign+='.';
			}
			cks[i]=assign;
			//cout<<cks[i]<<endl;
			assign="";
		}
		partial_sum();
		 int ck = 1;
	    for (int i = 0; i < n; i++) {
			  if(cks[i]!=s[i]){
			  	ck=0;
			  	break;
			  }
		}
		//cout << ck << endl;

		if (ck == 1) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				cout << vt[i].ss.ff + 1 << " " << vt[i].ss.ss + 1 << " " << vt[i].ff << endl;
			}
		}
		else {
			cout << -1 << endl;
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
//string cks[N],assign;
int partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				//cks[i][j] = '*';
				cnt++;
			}
		}
	} return cnt;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[N];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		//scanf("%d %d", &n, &m);
		cin>>n>>m;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = l[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i][j] == '.')cnt++;
			}

		}
		cnt = partial_sum();
		int ck = 1;

		//cout << ck << endl;

		if (cnt == n * m) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				printf("%d %d %d\n", vt[i].ss.ff + 1, vt[i].ss.ss + 1, vt[i].ff );
				//cout <<vt[i].ss.ff + 1 << " " << vt[i].ss.ss + 1 << " " << vt[i].ff << endl;
			}
		}
		else {
			printf("-1\n");
			//cout << -1 << endl;
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
//string cks[N],assign;
int partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				//cks[i][j] = '*';
				cnt++;
			}
		}
	}return cnt;

}
int main() {
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[1005];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		scanf("%d %d", &n, &m);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = l[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if(s[i][j]=='.')cnt++;
			}

		}
		cnt=partial_sum();
		 int ck = 1;

		//cout << ck << endl;

		if (cnt == n*m) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				cout << vt[i].ss.ff + 1 << " " << vt[i].ss.ss + 1 << " " << vt[i].ff << endl;
			}
		}
		else {
			cout << -1 << endl;
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
//string cks[N],assign;
int partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				//cks[i][j] = '*';
				cnt++;
			}
		}
	} return cnt;

}
int main() {
	cin.tie(NULL);
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[N];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		scanf("%d %d", &n, &m);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = l[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i][j] == '.')cnt++;
			}

		}
		cnt = partial_sum();
		int ck = 1;

		//cout << ck << endl;

		if (cnt == n * m) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				printf("%d %d %d\n", vt[i].ss.ff + 1, vt[i].ss.ss + 1, vt[i].ff );
			}
		}
		else {
			printf("-1\n");
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
string ck[N];
int partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				//ck[i][j]
				cnt++;
			}
		}
	}
	return cnt;
}
int main() {
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[1005];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		scanf("%d %d", &n, &m);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = r[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(d[i][j], r[i][j]), min(l[i][j], u[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i][j] == '.') {
					cnt++;
				}
			}
		}
		int ck = partial_sum();
		//cout << ck << endl;
		if (ck == n * m) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				cout << vt[i].ss.ff+1 << " " << vt[i].ss.ss+1 << " " << vt[i].ff << endl;
			}
		}
		else {
			cout << -1 << endl;
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
string cks[N],assign;
void partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				cks[i][j] = '*';

			}
		}
	}

}
int main() {
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[1005];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		scanf("%d %d", &n, &m);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = r[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				assign+='.';
			}
			cks[i]=assign;
			//cout<<cks[i]<<endl;
			assign="";
		}
		partial_sum();
		 int ck = 1;
	    for (int i = 0; i < n; i++) {
			  if(cks[i]!=s[i]){
			  	ck=0;
			  	break;
			  }
		}
		//cout << ck << endl;

		if (ck == 1) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				cout << vt[i].ss.ff + 1 << " " << vt[i].ss.ss + 1 << " " << vt[i].ff << endl;
			}
		}
		else {
			cout << -1 << endl;
		}
	}
	return 0;
}


/**Bismillahir Rahmanir Raheem
 Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e3 + 5;
const int M = 1e9 + 7;
const double pi = 2 * acos(0.0);
const double esp = 1e-9;
int Set(int N, int pos) {
	return N = N | (1 << pos);
}
int reset(int N, int pos) {
	return N = N & ~(1 << pos);
}
bool check(int N, int pos) {
	return (bool)(N & (1 << pos));
}
int l[N][N], r[N][N], u[N][N], d[N][N], cnt = 0, partial_x[N][N], partial_y[N][N], n, m;
vector<pair<int, pair<int, int> > > vt;
//string cks[N],assign;
int partial_sum() {
	for (int i = 0; i < vt.size(); i++) {
		int len = vt[i].ff;
		int ii = vt[i].ss.ff, j = vt[i].ss.ss;
		partial_y[ii - len][j] += 1;
		if (ii + len + 1 < n) {
			partial_y[ii + len + 1][j] += (-1);
		}
		partial_x[ii][j - len] += 1;
		if (j + len + 1 < m) {
			partial_x[ii][j + len + 1] += (-1);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i > 0) {
				partial_y[i][j] += partial_y[i - 1][j];
			}
			if (j > 0) {
				partial_x[i][j] += partial_x[i][j - 1];
			}
			if (partial_x[i][j] > 0 || partial_y[i][j] > 0) {
				//cks[i][j] = '*';
				cnt++;
			}
		}
	} return cnt;

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/// freopen("input.txt","r",stdin);
	/// freopen("output.txt","w",stdout);
	int test = 1; string s[N];
	///scanf("%d",&test);
	for (int cs = 1; cs <= test; cs++) {
		scanf("%d %d", &n, &m);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (j > 0) {
					if (s[i][j] == '*') {
						r[i][j] = r[i][j - 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						r[i][j] = 1;
					}
				}
				if (i > 0) {
					if (s[i][j] == '*') {
						d[i][j] = d[i - 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						d[i][j] = 1;
					}
				}
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			for (int j = m - 1; j >= 0; j--) {
				if (i + 1 < n) {
					if (s[i][j] == '*') {
						u[i][j] = u[i + 1][j] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						u[i][j] = 1;
					}
				}
				if (j + 1 < m) {
					if (s[i][j] == '*') {
						l[i][j] = l[i][j + 1] + 1;
					}
				}
				else {
					if (s[i][j] == '*') {
						l[i][j] = 1;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int len = min(min(l[i][j], r[i][j]), min(u[i][j], d[i][j])) - 1;
				if (len > 0) {
					vt.pb({len, {i, j}});
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s[i][j] == '.')cnt++;
			}

		}
		cnt = partial_sum();
		int ck = 1;

		//cout << ck << endl;

		if (cnt == n * m) {
			cout << vt.size() << endl;
			for (int i = 0; i < vt.size(); i++) {
				//printf("%d %d %d\n", vt[i].ss.ff + 1, vt[i].ss.ss + 1, vt[i].ff );
				cout <<vt[i].ss.ff + 1 << " " << vt[i].ss.ss + 1 << " " << vt[i].ff << endl;
			}
		}
		else {
			//printf("-1\n");
			cout << -1 << endl;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mpr make_pair
#define f first
#define s second

using namespace std;
//using namespace std::chrono;

const int sz = 1009; bool arr[sz][sz],out[sz][sz];
int16_t x,y,l[sz][sz],r[sz][sz],t[sz][sz],b[sz][sz];
int16_t A,B,C,D; char inp; vector < int > vec;

/*void pr( int x , int y ){
    cout << x << " " << y << endl;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ) cout << '*';
        cout << endl;
    }
}*/

int main(){

    ios::sync_with_stdio( 0 ); cin.tie(0);
    #ifndef ONLINE_JUDGE
        freopen( "InPut.txt"  , "r" , stdin  );
        freopen( "OutPut.txt" , "w" , stdout );
    #endif

    //pr( 1000 , 1000 ); return 0;

    cin >> x >> y; int counter = 0;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            cin >> inp;
            if ( inp == '*' ) arr[i][j] = 1;
        }
    }

    for ( int i = 0; i < x; i++ ){
        A = 0; B = 0;
        for ( int j = 0; j < y; j++ ){
            if ( arr[i][  j  ] ) A++;
            else A = 0;
            if ( arr[i][y-j-1] ) B++;
            else B = 0;
            l[i][j] = A;
            r[i][y-j-1] = B;
        }
    }
    for ( int i = 0; i < y; i++ ){
        C = 0; D = 0;
        for ( int j = 0; j < x; j++ ){
            if ( arr[  j  ][i] ) C++;
            else C = 0;
            if ( arr[x-j-1][i] ) D++;
            else D = 0;
            t[j][i] = C;
            b[x-j-1][i] = D;
        }
    }

    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            if ( arr[ i ][ j ] ){
                int16_t len = min( l[i][j] , r[i][j] );
                len = min( len , min( t[i][j] , b[i][j] ) );
                len--;

                if ( len > 0 ){
                    counter++;
                    out[i][j] = 1;
                    for ( int k = 1; k <= len; k++ ){
                        out[i][j+k] = 1;
                        out[i][j-k] = 1;
                        out[i+k][j] = 1;
                        out[i-k][j] = 1;
                    }
                }
            }
        }
    }

    if ( counter == 0 ) cout << 0;
    else{

        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[i][j] != out[i][j] ){
                    cout << -1;
                    return 0;
                }
            }
        }

        cout << counter << endl;
        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[ i ][ j ] ){
                    int16_t len = min( l[i][j] , r[i][j] );
                    len = min( len , min( t[i][j] , b[i][j] ) );
                    len--;
                    if ( len > 0 ){
                        cout << i+1 << " " << j+1 << " " << len << endl;
                    }
                }
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mpr make_pair
#define f first
#define s second

using namespace std;
//using namespace std::chrono;

const int sz = 1009; bool arr[sz][sz],out[sz][sz];
int16_t x,y,l[sz][sz],r[sz][sz],t[sz][sz],b[sz][sz];
int16_t A,B,C,D; char inp; vector < int > vec;

/*void pr( int x , int y ){
    cout << x << " " << y << endl;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ) cout << '*';
        cout << endl;
    }
}*/

int main(){

    ios::sync_with_stdio( 0 ); cin.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen( "InPut.txt"  , "r" , stdin  );
        //freopen( "OutPut.txt" , "w" , stdout );
    #endif

    //pr( 1000 , 1000 ); return 0;

    cin >> x >> y; int counter = 0;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            cin >> inp;
            if ( inp == '*' ) arr[i][j] = 1;
        }
    }

    for ( int i = 0; i < x; i++ ){
        A = 0; B = 0;
        for ( int j = 0; j < y; j++ ){
            if ( arr[i][  j  ] ) A++;
            else A = 0;
            if ( arr[i][y-j-1] ) B++;
            else B = 0;
            l[i][j] = A;
            r[i][y-j-1] = B;
        }
    }
    for ( int i = 0; i < y; i++ ){
        C = 0; D = 0;
        for ( int j = 0; j < x; j++ ){
            if ( arr[  j  ][i] ) C++;
            else C = 0;
            if ( arr[x-j-1][i] ) D++;
            else D = 0;
            t[j][i] = C;
            b[x-j-1][i] = D;
        }
    }

    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            if ( arr[ i ][ j ] ){
                int16_t len = min( l[i][j] , r[i][j] );
                len = min( len , min( t[i][j] , b[i][j] ) );
                len--;

                if ( len > 0 ){
                    counter++;
                    out[i][j] = 1;
                    for ( int k = 1; k <= len; k++ ){
                        out[i][j+k] = 1;
                        out[i][j-k] = 1;
                        out[i+k][j] = 1;
                        out[i-k][j] = 1;
                    }
                }
            }
        }
    }

    if ( counter == 0 ) cout << -1;
    else{

        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[i][j] != out[i][j] ){
                    cout << -1;
                    return 0;
                }
            }
        }

        cout << counter << endl;
        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[ i ][ j ] ){
                    int16_t len = min( l[i][j] , r[i][j] );
                    len = min( len , min( t[i][j] , b[i][j] ) );
                    len--;
                    if ( len > 0 ){
                        cout << i+1 << " " << j+1 << " " << len << endl;
                    }
                }
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mpr make_pair
#define f first
#define s second

using namespace std;
//using namespace std::chrono;

const int sz = 1009; bool arr[sz][sz],out[sz][sz];
int16_t x,y,l[sz][sz],r[sz][sz],t[sz][sz],b[sz][sz];
int16_t A,B,C,D; char inp; vector < int > vec;

int main(){

    ios::sync_with_stdio( 0 ); cin.tie(0);
    #ifndef ONLINE_JUDGE
        freopen( "InPut.txt"  , "r" , stdin  );
        freopen( "OutPut.txt" , "w" , stdout );
    #endif

    bool check = 1;
    cin >> x >> y; int counter = 0;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            cin >> inp;
            if ( inp == '*' ) arr[i][j] = 1,check = 0;
        }
    }
    if ( check ){ cout << 0; return 0; }
    for ( int i = 0; i < x; i++ ){
        A = 0; B = 0;
        for ( int j = 0; j < y; j++ ){
            if ( arr[i][  j  ] ) A++;
            else A = 0;
            if ( arr[i][y-j-1] ) B++;
            else B = 0;
            l[i][j] = A;
            r[i][y-j-1] = B;
        }
    }
    for ( int i = 0; i < y; i++ ){
        C = 0; D = 0;
        for ( int j = 0; j < x; j++ ){
            if ( arr[  j  ][i] ) C++;
            else C = 0;
            if ( arr[x-j-1][i] ) D++;
            else D = 0;
            t[j][i] = C;
            b[x-j-1][i] = D;
        }
    }

    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            if ( arr[ i ][ j ] ){
                int16_t len = min( l[i][j] , r[i][j] );
                len = min( len , min( t[i][j] , b[i][j] ) );
                len--;

                if ( len > 0 ){
                    counter++;
                    out[i][j] = 1;
                    for ( int k = 1; k <= len; k++ ){
                        out[i][j+k] = 1;
                        out[i][j-k] = 1;
                        out[i+k][j] = 1;
                        out[i-k][j] = 1;
                    }
                }
            }
        }
    }

    if ( counter == 0 ) cout << -1;
    else{

        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[i][j] != out[i][j] ){
                    cout << -1;
                    return 0;
                }
            }
        }

        cout << counter << endl;
        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[ i ][ j ] ){
                    int16_t len = min( l[i][j] , r[i][j] );
                    len = min( len , min( t[i][j] , b[i][j] ) );
                    len--;
                    if ( len > 0 ){
                        cout << i+1 << " " << j+1 << " " << len << endl;
                    }
                }
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mpr make_pair
#define f first
#define s second

using namespace std;
//using namespace std::chrono;

const int sz = 1009; bool arr[sz][sz],out[sz][sz];
int16_t x,y,l[sz][sz],r[sz][sz],t[sz][sz],b[sz][sz];
int16_t A,B,C,D; char inp; vector < int > vec;

/*void pr( int x , int y ){
    cout << x << " " << y << endl;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ) cout << '*';
        cout << endl;
    }
}*/

int main(){

    ios::sync_with_stdio( 0 ); cin.tie(0);
    #ifndef ONLINE_JUDGE
        freopen( "InPut.txt"  , "r" , stdin  );
        freopen( "OutPut.txt" , "w" , stdout );
    #endif

    //pr( 1000 , 1000 ); return 0;

    cin >> x >> y; int counter = 0;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            cin >> inp;
            if ( inp == '*' ) arr[i][j] = 1;
        }
    }

    for ( int i = 0; i < x; i++ ){
        A = 0; B = 0;
        for ( int j = 0; j < y; j++ ){
            if ( arr[i][  j  ] ) A++;
            if ( arr[i][y-j-1] ) B++;
            l[i][j] = A;
            r[i][y-j-1] = B;
        }
    }
    for ( int i = 0; i < y; i++ ){
        C = 0; D = 0;
        for ( int j = 0; j < x; j++ ){
            if ( arr[  j  ][i] ) C++;
            if ( arr[x-j-1][i] ) D++;
            t[j][i] = C;
            b[x-j-1][i] = D;
        }
    }

    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            if ( arr[ i ][ j ] ){
                int16_t len = min( l[i][j] , r[i][j] );
                len = min( len , min( t[i][j] , b[i][j] ) );
                len--;

                if ( len > 0 ){
                    vec.push_back( i );
                    vec.push_back( j );
                    vec.push_back(len-1);
                    out[i][j] = 1;
                    for ( int k = 1; k <= len; k++ ){
                        out[i][j+k] = 1;
                        out[i][j-k] = 1;
                        out[i+k][j] = 1;
                        out[i-k][j] = 1;
                    }
                }
            }
        }
    }

    if ( vec.size() == 0 ) cout << -1;
    else{

        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[i][j] != out[i][j] ){
                    cout << -1;
                    return 0;
                }
            }
        }

        cout << vec.size()/3 << endl;
        for ( int i = 0; i < vec.size(); i++ ){
            if ( i%3 == 0 && i > 0 ) cout << endl;
            cout << vec[i]+1 << " ";
        }

        /*cout << counter << endl;
        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[ i ][ j ] ){
                    int16_t len = min( l[i][j] , r[i][j] );
                    len = min( len , min( t[i][j] , b[i][j] ) );
                    len--;
                    if ( len > 0 ){
                        cout << i+1 << " " << j+1 << " " << len << endl;
                    }
                }
            }
        }*/
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mpr make_pair
#define f first
#define s second

using namespace std;
//using namespace std::chrono;

const int sz = 1009; bool arr[sz][sz],out[sz][sz];
int16_t x,y,l[sz][sz],r[sz][sz],t[sz][sz],b[sz][sz];
int16_t A,B,C,D; char inp;

/*void pr( int x , int y ){
    cout << x << " " << y << endl;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ) cout << '*';
        cout << endl;
    }
}*/

int main(){

    ios::sync_with_stdio( 0 ); cin.tie(0);
    #ifndef ONLINE_JUDGE
        freopen( "InPut.txt"  , "r" , stdin  );
        freopen( "OutPut.txt" , "w" , stdout );
    #endif

    //pr( 1000 , 1000 ); return 0;

    cin >> x >> y; int counter = 0;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            cin >> inp;
            if ( inp == '*' ) arr[i][j] = 1;
        }
    }

    for ( int i = 0; i < x; i++ ){
        A = 0; B = 0;
        for ( int j = 0; j < y; j++ ){
            if ( arr[i][  j  ] ) A++;
            if ( arr[i][y-j-1] ) B++;
            l[i][j] = A;
            r[i][y-j-1] = B;
        }
    }
    for ( int i = 0; i < y; i++ ){
        C = 0; D = 0;
        for ( int j = 0; j < x; j++ ){
            if ( arr[  j  ][i] ) C++;
            if ( arr[x-j-1][i] ) D++;
            t[j][i] = C;
            b[x-j-1][i] = D;
        }
    }

    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            if ( arr[ i ][ j ] ){
                int16_t len = min( l[i][j] , r[i][j] );
                len = min( len , min( t[i][j] , b[i][j] ) );
                len--;
                if ( len > 0 ){
                    counter++;
                    out[i][j] = 1;
                    for ( int k = 1; k <= len; k++ ){
                        out[i][j+k] = 1;
                        out[i][j-k] = 1;
                        out[i+k][j] = 1;
                        out[i-k][j] = 1;
                    }
                }
            }
        }
    }

    if ( counter == 0 ) cout << -1;
    else{

        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[i][j] != out[i][j] ){
                    cout << -1;
                    return 0;
                }
            }
        }

        cout << counter << endl;
        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[ i ][ j ] ){
                    int16_t len = min( l[i][j] , r[i][j] );
                    len = min( len , min( t[i][j] , b[i][j] ) );
                    len--;
                    if ( len > 0 ){
                        cout << i+1 << " " << j+1 << " " << len << endl;
                    }
                }
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mpr make_pair
#define f first
#define s second

using namespace std;
//using namespace std::chrono;

const int sz = 1009; bool arr[sz][sz],out[sz][sz];
int16_t x,y,l[sz][sz],r[sz][sz],t[sz][sz],b[sz][sz];
int16_t A,B,C,D; char inp; vector < int > vec;

/*void pr( int x , int y ){
    cout << x << " " << y << endl;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ) cout << '*';
        cout << endl;
    }
}*/

int main(){

    ios::sync_with_stdio( 0 ); cin.tie(0);
    #ifndef ONLINE_JUDGE
        freopen( "InPut.txt"  , "r" , stdin  );
        freopen( "OutPut.txt" , "w" , stdout );
    #endif

    //pr( 1000 , 1000 ); return 0;

    cin >> x >> y; int counter = 0;
    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            cin >> inp;
            if ( inp == '*' ) arr[i][j] = 1;
        }
    }

    for ( int i = 0; i < x; i++ ){
        A = 0; B = 0;
        for ( int j = 0; j < y; j++ ){
            if ( arr[i][  j  ] ) A++;
            if ( arr[i][y-j-1] ) B++;
            l[i][j] = A;
            r[i][y-j-1] = B;
        }
    }
    for ( int i = 0; i < y; i++ ){
        C = 0; D = 0;
        for ( int j = 0; j < x; j++ ){
            if ( arr[  j  ][i] ) C++;
            if ( arr[x-j-1][i] ) D++;
            t[j][i] = C;
            b[x-j-1][i] = D;
        }
    }

    for ( int i = 0; i < x; i++ ){
        for ( int j = 0; j < y; j++ ){
            if ( arr[ i ][ j ] ){
                int16_t len = min( l[i][j]-1 , r[i][j]-1 );
                len = min( len , min( t[i][j]-1 , b[i][j]-1 ) );

                if ( len > 0 ){
                    vec.push_back( i );
                    vec.push_back( j );
                    vec.push_back(len-1);
                    out[i][j] = 1;
                    for ( int k = 1; k <= len; k++ ){
                        out[i][j+k] = 1;
                        out[i][j-k] = 1;
                        out[i+k][j] = 1;
                        out[i-k][j] = 1;
                    }
                }
            }
        }
    }

    if ( vec.size() == 0 ) cout << -1;
    else{

        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[i][j] != out[i][j] ){
                    cout << -1;
                    return 0;
                }
            }
        }

        cout << vec.size()/3 << endl;
        for ( int i = 0; i < vec.size(); i++ ){
            if ( i%3 == 0 && i > 0 ) cout << endl;
            cout << vec[i]+1 << " ";
        }

        /*cout << counter << endl;
        for ( int i = 0; i < x; i++ ){
            for ( int j = 0; j < y; j++ ){
                if ( arr[ i ][ j ] ){
                    int16_t len = min( l[i][j] , r[i][j] );
                    len = min( len , min( t[i][j] , b[i][j] ) );
                    len--;
                    if ( len > 0 ){
                        cout << i+1 << " " << j+1 << " " << len << endl;
                    }
                }
            }
        }*/
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define sf              scanf
#define pf              printf
#define cases           ll T;cin>>T;for(int TC=1;TC<=T;TC++)
#define pi              3.1415926535897932384626433832795l
#define ignore          cin.ignore();
#define mem(n,i)        memset(n,i,sizeof n);
#define precision(n)    cout<<fixed<<setprecision(n);
#define bug()           cerr<<"**********\n";
#define pb              push_back
#define MOD             1000000007
#define cout(x)         cout<<"Case "<<TC<<": "<<x<<endl
#define EPS             1e-9
#define mp              make_pair
typedef unsigned long long ull;
typedef long long ll;
vector <pair <int,int > > pos;
char draw[1000][1000];
int r1[1001][1001];
int r2[1001][1001];
int c1[1001][1001];
int c2[1001][1001];
int stars[1001][1001];
int m,n,LEFT,RIGHT,UP,DOWN;
vector <pair<int ,int >> store;
inline int check(int x, int y)
{

    LEFT=r1[x][y]-1;
    RIGHT=r2[x][y]-1;
    UP=c1[x][y]-1;
    DOWN=c2[x][y]-1;
    int SIZE= min(min(min(UP,DOWN),LEFT),RIGHT);
    return SIZE;
}
int main()
{

    sf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        sf("%s",draw+i);

    int x,y;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                pos.pb({i,j});
                r1[i][j]=1;
                r2[i][j]=1;
                c1[i][j]=1;
                c2[i][j]=1;
            }
        }
    }
    for(int i=0,k=0;i<n;i++,k++)
    {
        for(int j=1,l=m-2;j<m;j++,l--)
        {
            if(r1[i][j]!=0)
                r1[i][j]+=r1[i][j-1];
            if(r2[k][l]!=0)
                r2[k][l]+=r2[k][l+1];
        }
    }
    for(int i=0,k=0;i<m;i++,k++)
    {
        for(int j=1,l=n-2;j<n;j++,l--)
        {
            if(c1[j][i]!=0)
                c1[j][i]+=c1[j-1][i];
            if(c2[l][k]!=0)
                c2[l][k]+=c2[l+1][k];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                int SIZE=check(i,j);
                if(SIZE)
                {
                    store.pb({i,j});
                    stars[i][j]=SIZE;
                }
            }
        }
    }
    int StoreSize=store.size();
    int posSIZE=pos.size();

    for(int i=0;i<posSIZE;i++)
    {

        int count=0;
        for(int j=0;j<StoreSize;j++)
        {

            int X=store[j].first;
            int Y=store[j].second;
            int SIZE=stars[X][Y];

            if  ((pos[i].first==X && pos[i].second>= (Y-SIZE) && pos[i].second<=(Y+SIZE)) ||
                 (pos[i].second==Y && pos[i].first>= (X-SIZE) && pos[i].first<=(X+SIZE)))
            {

            }
            else
                count++;
        }
        if(count==StoreSize)
        {
            puts("-1");
            return 0;

        }
    }
    pf("%d\n",StoreSize);
    for(int i=0;i<StoreSize;i++)
        pf("%d %d %d\n",store[i].first+1,store[i].second+1,stars[store[i].first][store[i].second]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define sf              scanf
#define pf              printf
#define cases           ll T;cin>>T;for(int TC=1;TC<=T;TC++)
#define pi              3.1415926535897932384626433832795l
#define ignore          cin.ignore();
#define mem(n,i)        memset(n,i,sizeof n);
#define precision(n)    cout<<fixed<<setprecision(n);
#define bug()           cerr<<"**********\n";
#define pb              push_back
#define MOD             1000000007
#define cout(x)         cout<<"Case "<<TC<<": "<<x<<endl
#define EPS             1e-9
#define mp              make_pair
typedef unsigned long long ull;
typedef long long ll;
vector <pair <int,int > > pos;
char draw[1000][1000];
int r1[1001][1001];
int r2[1001][1001];
int c1[1001][1001];
int c2[1001][1001];
int stars[1001][1001];
int m,n,LEFT,RIGHT,UP,DOWN;
vector <pair<int ,int >> store;
int main()
{

    sf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        sf("%s",draw+i);

    int x,y;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                pos.pb({i,j});
                r1[i][j]=1;
                r2[i][j]=1;
                c1[i][j]=1;
                c2[i][j]=1;
            }
        }
    }
    for(int i=0,k=0;i<n;i++,k++)
    {
        for(int j=1,l=m-2;j<m;j++,l--)
        {
            if(r1[i][j]!=0)
                r1[i][j]+=r1[i][j-1];
            if(r2[k][l]!=0)
                r2[k][l]+=r2[k][l+1];
        }
    }
    for(int i=0,k=0;i<m;i++,k++)
    {
        for(int j=1,l=n-2;j<n;j++,l--)
        {
            if(c1[j][i]!=0)
                c1[j][i]+=c1[j-1][i];
            if(c2[l][k]!=0)
                c2[l][k]+=c2[l+1][k];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                LEFT=r1[x][y]-1;
                RIGHT=r2[x][y]-1;
                UP=c1[x][y]-1;
                DOWN=c2[x][y]-1;
                int SIZE= min(min(min(UP,DOWN),LEFT),RIGHT);
                if(SIZE)
                {
                    store.pb({i,j});
                    stars[i][j]=SIZE;
                }
            }
        }
    }
    int StoreSize=store.size();
    int posSIZE=pos.size();

    for(int i=0;i<posSIZE;i++)
    {

        int count=0;
        for(int j=0;j<StoreSize;j++)
        {

            int X=store[j].first;
            int Y=store[j].second;
            int SIZE=stars[X][Y];

            if  ((pos[i].first==X && pos[i].second>= (Y-SIZE) && pos[i].second<=(Y+SIZE)) ||
                 (pos[i].second==Y && pos[i].first>= (X-SIZE) && pos[i].first<=(X+SIZE)))
            {

            }
            else
                count++;
        }
        if(count==StoreSize)
        {
            puts("-1");
            return 0;

        }
    }
    pf("%d\n",StoreSize);
    for(int i=0;i<StoreSize;i++)
        pf("%d %d %d\n",store[i].first+1,store[i].second+1,stars[store[i].first][store[i].second]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define sf              scanf
#define pf              printf
#define cases           ll T;cin>>T;for(int TC=1;TC<=T;TC++)
#define pi              3.1415926535897932384626433832795l
#define ignore          cin.ignore();
#define mem(n,i)        memset(n,i,sizeof n);
#define precision(n)    cout<<fixed<<setprecision(n);
#define bug()           cerr<<"**********\n";
#define pb              push_back
#define MOD             1000000007
#define cout(x)         cout<<"Case "<<TC<<": "<<x<<endl
#define EPS             1e-9
#define mp              make_pair
typedef unsigned long long ull;
typedef long long ll;
vector <pair <int,int > > pos;
char draw[1000][1000];
int r1[1001][1001];
int r2[1001][1001];
int c1[1001][1001];
int c2[1001][1001];
int stars[1001][1001];
int m,n,LEFT,RIGHT,UP,DOWN;
vector <pair<int ,int >> store;
inline int check(int x, int y)
{

    LEFT=r1[x][y]-1;
    RIGHT=r2[x][y]-1;
    UP=c1[x][y]-1;
    DOWN=c2[x][y]-1;
    int SIZE= min(min(min(UP,DOWN),LEFT),RIGHT);
    return SIZE;
}
int main()
{

    sf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
        sf("%s",draw[i]);

    int x,y;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                pos.pb({i,j});
                r1[i][j]=1;
                r2[i][j]=1;
                c1[i][j]=1;
                c2[i][j]=1;
            }
        }
    }
    for(int i=0,k=0;i<n;i++,k++)
    {
        for(int j=1,l=m-2;j<m;j++,l--)
        {
            if(r1[i][j]!=0)
                r1[i][j]+=r1[i][j-1];
            if(r2[k][l]!=0)
                r2[k][l]+=r2[k][l+1];
        }
    }
    for(int i=0,k=0;i<m;i++,k++)
    {
        for(int j=1,l=n-2;j<n;j++,l--)
        {
            if(c1[j][i]!=0)
                c1[j][i]+=c1[j-1][i];
            if(c2[l][k]!=0)
                c2[l][k]+=c2[l+1][k];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                int SIZE=check(i,j);
                if(SIZE)
                {
                    store.pb({i,j});
                    stars[i][j]=SIZE;
                }
            }
        }
    }
    bool flag=true;
    int StoreSize=store.size();
    int posSIZE=pos.size();
    if(StoreSize>0)
    for(int i=0;i<posSIZE;i++)
    {

        int count=0;
        for(int j=0;j<StoreSize;j++)
        {

            int X=store[j].first;
            int Y=store[j].second;
            int SIZE=stars[X][Y];

            if  ((pos[i].first==X && pos[i].second>= (Y-SIZE) && pos[i].second<=(Y+SIZE)) ||
                 (pos[i].second==Y && pos[i].first>= (X-SIZE) && pos[i].first<=(X+SIZE)))
            {

            }
            else
                count++;
        }
        if(count==StoreSize)
        {
            flag=false;
            break;
        }
    }
    if(flag)
    {
        pf("%d\n",StoreSize);
        for(int i=0;i<StoreSize;i++)
            pf("%d %d %d\n",store[i].first+1,store[i].second+1,stars[store[i].first][store[i].second]);
    }
    else
        pf("-1\n");
}


#include <bits/stdc++.h>
using namespace std;
#define sf              scanf
#define pf              printf
#define cases           ll T;cin>>T;for(int TC=1;TC<=T;TC++)
#define pi              3.1415926535897932384626433832795l
#define ignore          cin.ignore();
#define mem(n,i)        memset(n,i,sizeof n);
#define precision(n)    cout<<fixed<<setprecision(n);
#define bug()           cerr<<"**********\n";
#define pb              push_back
#define MOD             1000000007
#define cout(x)         cout<<"Case "<<TC<<": "<<x<<endl
#define EPS             1e-9
#define mp              make_pair
typedef unsigned long long ull;
typedef long long ll;
vector <pair <int,int > > pos;
char draw[1000][1000];
int r1[1001][1001];
int r2[1001][1001];
int c1[1001][1001];
int c2[1001][1001];
int m,n,LEFT,RIGHT,UP,DOWN;
struct FX {
int x,y,s;
};
vector <FX> store;
int check(int x, int y)
{

    LEFT=r1[x][y]-1;
    RIGHT=r2[x][y]-1;
    UP=c1[x][y]-1;
    DOWN=c2[x][y]-1;
    int SIZE= min(min(min(UP,DOWN),LEFT),RIGHT);
    return SIZE;
}
int main()
{

    sf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
        sf("%s",draw[i]);

    int x,y;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                pos.pb({i,j});
                r1[i][j]=1;
                r2[i][j]=1;
                c1[i][j]=1;
                c2[i][j]=1;
            }
        }
    }
    for(int i=0,k=0;i<n;i++,k++)
    {
        for(int j=1,l=m-2;j<m;j++,l--)
        {
            if(r1[i][j]!=0)
                r1[i][j]+=r1[i][j-1];
            if(r2[k][l]!=0)
                r2[k][l]+=r2[k][l+1];
        }
    }

    for(int i=0,k=0;i<m;i++,k++)
    {
        for(int j=1,l=n-2;j<n;j++,l--)
        {
            if(c1[j][i]!=0)
                c1[j][i]+=c1[j-1][i];
            if(c2[l][k]!=0)
                c2[l][k]+=c2[l+1][k];
        }
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                int SIZE=check(i,j);
                if(SIZE)
                {
                    store.push_back({i,j,SIZE});
                }
            }
        }
    }

    bool flag=true;
    int StoreSize=store.size();
    for(int i=0;i<pos.size();i++)
    {

        int count=0;
        for(int j=0;j<store.size();j++)
        {

            int SIZE=store[j].s;
            int X=store[j].x;
            int Y=store[j].y;
            if  ((pos[i].first==X && pos[i].second>= (Y-SIZE) && pos[i].second<=(Y+SIZE)) ||
                 (pos[i].second==Y && pos[i].first>= (X-SIZE) && pos[i].first<=(X+SIZE)))
            {

            }
            else
                count++;
        }
        if(count==StoreSize)
        {
            flag=false;
            break;
        }
    }
    if(flag)
    {
        pf("%d\n",store.size());
        for(int i=0;i<store.size();i++)
            pf("%d %d %d\n",store[i].x+1,store[i].y+1,store[i].s);
    }
    else
        pf("-1\n");
}


#include <bits/stdc++.h>
using namespace std;
#define sf              scanf
#define pf              printf
#define cases           ll T;cin>>T;for(int TC=1;TC<=T;TC++)
#define pi              3.1415926535897932384626433832795l
#define ignore          cin.ignore();
#define mem(n,i)        memset(n,i,sizeof n);
#define precision(n)    cout<<fixed<<setprecision(n);
#define bug()           cerr<<"**********\n";
#define pb              push_back
#define MOD             1000000007
#define cout(x)         cout<<"Case "<<TC<<": "<<x<<endl
#define EPS             1e-9
#define mp              make_pair
typedef unsigned long long ull;
typedef long long ll;
vector <pair <int,int > > pos;
char draw[1000][1000];
int r1[1001][1001];
int r2[1001][1001];
int c1[1001][1001];
int c2[1001][1001];
int stars[1001][1001];
int m,n,LEFT,RIGHT,UP,DOWN;
vector <pair<int ,int >> store;
int check(int x, int y)
{

    LEFT=r1[x][y]-1;
    RIGHT=r2[x][y]-1;
    UP=c1[x][y]-1;
    DOWN=c2[x][y]-1;
    int SIZE= min(min(min(UP,DOWN),LEFT),RIGHT);
    return SIZE;
}
int main()
{

    sf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
        sf("%s",draw[i]);

    int x,y;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                pos.pb({i,j});
                r1[i][j]=1;
                r2[i][j]=1;
                c1[i][j]=1;
                c2[i][j]=1;
            }
        }
    }
    for(int i=0,k=0;i<n;i++,k++)
    {
        for(int j=1,l=m-2;j<m;j++,l--)
        {
            if(r1[i][j]!=0)
                r1[i][j]+=r1[i][j-1];
            if(r2[k][l]!=0)
                r2[k][l]+=r2[k][l+1];
        }
    }
    for(int i=0,k=0;i<m;i++,k++)
    {
        for(int j=1,l=n-2;j<n;j++,l--)
        {
            if(c1[j][i]!=0)
                c1[j][i]+=c1[j-1][i];
            if(c2[l][k]!=0)
                c2[l][k]+=c2[l+1][k];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                int SIZE=check(i,j);
                if(SIZE)
                {
                    store.pb({i,j});
                    stars[i][j]=SIZE;
                }
            }
        }
    }
    bool flag=true;
    int StoreSize=store.size();
    int posSIZE=pos.size();
    for(int i=0;i<posSIZE;i++)
    {

        int count=0;
        for(int j=0;j<StoreSize;j++)
        {

            int X=store[j].first;
            int Y=store[j].second;
            int SIZE=stars[X][Y];

            if  ((pos[i].first==X && pos[i].second>= (Y-SIZE) && pos[i].second<=(Y+SIZE)) ||
                 (pos[i].second==Y && pos[i].first>= (X-SIZE) && pos[i].first<=(X+SIZE)))
            {

            }
            else
                count++;
        }
        if(count==StoreSize)
        {
            flag=false;
            break;
        }
    }
    if(flag)
    {
        pf("%d\n",StoreSize);
        for(int i=0;i<StoreSize;i++)
            pf("%d %d %d\n",store[i].first+1,store[i].second+1,stars[store[i].first][store[i].second]);
    }
    else
        pf("-1\n");
}


#include <bits/stdc++.h>
using namespace std;
#define sf              scanf
#define pf              printf
#define cases           ll T;cin>>T;for(int TC=1;TC<=T;TC++)
#define pi              3.1415926535897932384626433832795l
#define ignore          cin.ignore();
#define mem(n,i)        memset(n,i,sizeof n);
#define precision(n)    cout<<fixed<<setprecision(n);
#define bug()           cerr<<"**********\n";
#define pb              push_back
#define MOD             1000000007
#define cout(x)         cout<<"Case "<<TC<<": "<<x<<endl
#define EPS             1e-9
#define mp              make_pair
typedef unsigned long long ull;
typedef long long ll;
vector <pair <int,int > > pos;
char draw[1000][1000];
int r1[1001][1001];
int r2[1001][1001];
int c1[1001][1001];
int c2[1001][1001];
int stars[1001][1001];
int blue[1001][1001];
int m,n,LEFT,RIGHT,UP,DOWN;
vector <pair<int ,int >> store;
int main()
{

    sf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        sf("%s",draw+i);

    int x,y;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                pos.pb({i,j});
                r1[i][j]=1;
                r2[i][j]=1;
                c1[i][j]=1;
                c2[i][j]=1;
            }
        }
    }
    for(int i=0,k=0;i<n;i++,k++)
    {
        for(int j=1,l=m-2;j<m;j++,l--)
        {
            if(r1[i][j]!=0)
                r1[i][j]+=r1[i][j-1];
            if(r2[k][l]!=0)
                r2[k][l]+=r2[k][l+1];
        }
    }
    for(int i=0,k=0;i<m;i++,k++)
    {
        for(int j=1,l=n-2;j<n;j++,l--)
        {
            if(c1[j][i]!=0)
                c1[j][i]+=c1[j-1][i];
            if(c2[l][k]!=0)
                c2[l][k]+=c2[l+1][k];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                LEFT=r1[i][j]-1;
                RIGHT=r2[i][j]-1;
                UP=c1[i][j]-1;
                DOWN=c2[i][j]-1;
                int SIZE= min(min(UP,DOWN),min(LEFT,RIGHT));
                if(SIZE)
                {
                    store.pb({i,j});
                    blue[i][j-SIZE]++;
                    blue[i][j+SIZE+1]--;
                    blue[i-SIZE][j]++;
                    blue[i+SIZE+1][j]--;
                }
            }
        }
    }

    int StoreSize=store.size();
    int posSIZE=pos.size();
    for(int i=0;i<posSIZE;i++)
    {
        int count=0;
        if(stars[pos[i].first][pos[i].second]!=0)
            continue;
        for(int j=0;j<StoreSize;j++)
        {

            int X=store[j].first;
            int Y=store[j].second;
            int SIZE=stars[X][Y];

            if  ((pos[i].first==X && pos[i].second>= (Y-SIZE) && pos[i].second<=(Y+SIZE)) ||
                 (pos[i].second==Y && pos[i].first>= (X-SIZE) && pos[i].first<=(X+SIZE)))
            {

            }
            else
                count++;
        }
        if(count==StoreSize)
        {
            puts("-1");
            return 0;
        }
    }
    pf("%d\n",StoreSize);
    for(int i=0;i<StoreSize;i++)
        pf("%d %d %d\n",store[i].first+1,store[i].second+1,stars[store[i].first][store[i].second]);
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
#define sf              scanf
#define pf              printf
#define cases           ll T;cin>>T;for(int TC=1;TC<=T;TC++)
#define pi              3.1415926535897932384626433832795l
#define ignore          cin.ignore();
#define mem(n,i)        memset(n,i,sizeof n);
#define precision(n)    cout<<fixed<<setprecision(n);
#define bug()           cerr<<"**********\n";
#define pb              push_back
#define MOD             1000000007
#define cout(x)         cout<<"Case "<<TC<<": "<<x<<endl
#define EPS             1e-9
#define mp              make_pair
typedef unsigned long long ull;
typedef long long ll;
vector <pair <int,int > > pos;
char draw[1000][1000];
int r1[1001][1001];
int r2[1001][1001];
int c1[1001][1001];
int c2[1001][1001];
int stars[1001][1001];
int m,n,LEFT,RIGHT,UP,DOWN;
vector <pair<int ,int >> store;

int main()
{

    sf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        sf("%s",draw+i);

    int x,y;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                pos.pb({i,j});
                r1[i][j]=1;
                r2[i][j]=1;
                c1[i][j]=1;
                c2[i][j]=1;
            }
        }
    }
    for(int i=0,k=0;i<n;i++,k++)
    {
        for(int j=1,l=m-2;j<m;j++,l--)
        {
            if(r1[i][j]!=0)
                r1[i][j]+=r1[i][j-1];
            if(r2[k][l]!=0)
                r2[k][l]+=r2[k][l+1];
        }
    }
    for(int i=0,k=0;i<m;i++,k++)
    {
        for(int j=1,l=n-2;j<n;j++,l--)
        {
            if(c1[j][i]!=0)
                c1[j][i]+=c1[j-1][i];
            if(c2[l][k]!=0)
                c2[l][k]+=c2[l+1][k];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                LEFT=r1[i][j]-1;
                RIGHT=r2[i][j]-1;
                UP=c1[i][j]-1;
                DOWN=c2[i][j]-1;
                int SIZE= min(min(min(UP,DOWN),LEFT),RIGHT);
                if(SIZE)
                {
                    store.pb({i,j});
                    stars[i][j]=SIZE;
                }
            }
        }
    }
    int StoreSize=store.size();
    int posSIZE=pos.size();

    for(int i=0;i<posSIZE;i++)
    {

        int count=0;
        if(stars[pos[i].first][pos[i].second]!=0)
          continue;
        for(int j=0;j<StoreSize;j++)
        {

            int X=store[j].first;
            int Y=store[j].second;
            int SIZE=stars[X][Y];

            if  ((pos[i].first==X && pos[i].second>= (Y-SIZE) && pos[i].second<=(Y+SIZE)) ||
                 (pos[i].second==Y && pos[i].first>= (X-SIZE) && pos[i].first<=(X+SIZE)))
            {

            }
            else
                count++;
        }
        if(count==StoreSize)
        {
            puts("-1");
            return 0;

        }
    }
    pf("%d\n",StoreSize);
    for(int i=0;i<StoreSize;i++)
        pf("%d %d %d\n",store[i].first+1,store[i].second+1,stars[store[i].first][store[i].second]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define sf              scanf
#define pf              printf
#define cases           ll T;cin>>T;for(int TC=1;TC<=T;TC++)
#define pi              3.1415926535897932384626433832795l
#define ignore          cin.ignore();
#define mem(n,i)        memset(n,i,sizeof n);
#define precision(n)    cout<<fixed<<setprecision(n);
#define bug()           cerr<<"**********\n";
#define pb              push_back
#define MOD             1000000007
#define cout(x)         cout<<"Case "<<TC<<": "<<x<<endl
#define EPS             1e-9
#define mp              make_pair
typedef unsigned long long ull;
typedef long long ll;
vector <pair <int,int > > pos;
char draw[1000][1000];
int r1[1001][1001];
int r2[1001][1001];
int c1[1001][1001];
int c2[1001][1001];
int m,n,LEFT,RIGHT,UP,DOWN;

struct FX {
int x,y,s;
};
vector <FX> store;
int check(int x, int y)
{

    LEFT=r1[x][y]-1;
    RIGHT=r2[x][y]-1;
    UP=c1[x][y]-1;
    DOWN=c2[x][y]-1;
    int SIZE= min(min(min(UP,DOWN),LEFT),RIGHT);
    return SIZE;
}
int main()
{

    sf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
        sf("%s",draw[i]);

    int x,y;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                pos.pb({i,j});
                r1[i][j]=1;
                r2[i][j]=1;
                c1[i][j]=1;
                c2[i][j]=1;
            }
        }
    }
    for(int i=0,k=0;i<n;i++,k++)
    {
        for(int j=1,l=m-2;j<m;j++,l--)
        {
            if(r1[i][j]!=0)
                r1[i][j]+=r1[i][j-1];
            if(r2[k][l]!=0)
                r2[k][l]+=r2[k][l+1];
        }
    }

    for(int i=0,k=0;i<m;i++,k++)
    {
        for(int j=1,l=n-2;j<n;j++,l--)
        {
            if(c1[j][i]!=0)
                c1[j][i]+=c1[j-1][i];
            if(c2[l][k]!=0)
                c2[l][k]+=c2[l+1][k];
        }
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                int SIZE=check(i,j);
                if(SIZE)
                {
                    store.push_back({i,j,SIZE});
                }

            }
        }
    }

    bool flag=true;
    for(int i=0;i<pos.size();i++)
    {

        int count=0;
        for(int j=0;j<store.size();j++)
        {

            int SIZE=store[j].s;
            int X=store[j].x;
            int Y=store[j].y;
            if  ((pos[i].first==X && pos[i].second>= (Y-SIZE) && pos[i].second<=(Y+SIZE)) ||
                 (pos[i].second==Y && pos[i].first>= (X-SIZE) && pos[i].first<=(X+SIZE)))
            {

            }
            else
                count++;
        }
        if(count==store.size())
        {
            flag=false;
            break;
        }
    }
    if(flag)
    {
        pf("%d\n",store.size());
        for(int i=0;i<store.size();i++)
            pf("%d %d %d\n",store[i].x+1,store[i].y+1,store[i].s);
    }
    else
        pf("-1\n");
}


#include <bits/stdc++.h>
using namespace std;
#define sf              scanf
#define pf              printf
#define cases           ll T;cin>>T;for(int TC=1;TC<=T;TC++)
#define pi              3.1415926535897932384626433832795l
#define ignore          cin.ignore();
#define mem(n,i)        memset(n,i,sizeof n);
#define precision(n)    cout<<fixed<<setprecision(n);
#define bug()           cerr<<"**********\n";
#define pb              push_back
#define MOD             1000000007
#define cout(x)         cout<<"Case "<<TC<<": "<<x<<endl
#define EPS             1e-9
#define mp              make_pair
typedef unsigned long long ull;
typedef long long ll;
vector <pair <int,int > > pos;
char draw[1000][1000];
int r1[1001][1001];
int r2[1001][1001];
int c1[1001][1001];
int c2[1001][1001];
int stars[1001][1001];
int m,n,LEFT,RIGHT,UP,DOWN;
vector <pair<int ,int >> store;
inline int check(int x, int y)
{

    LEFT=r1[x][y]-1;
    RIGHT=r2[x][y]-1;
    UP=c1[x][y]-1;
    DOWN=c2[x][y]-1;
    int SIZE= min(min(min(UP,DOWN),LEFT),RIGHT);
    return SIZE;
}
int main()
{

    sf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        sf("%s",draw+i);

    int x,y;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                pos.pb({i,j});
                r1[i][j]=1;
                r2[i][j]=1;
                c1[i][j]=1;
                c2[i][j]=1;
            }
        }
    }
    for(int i=0,k=0;i<n;i++,k++)
    {
        for(int j=1,l=m-2;j<m;j++,l--)
        {
            if(r1[i][j]!=0)
                r1[i][j]+=r1[i][j-1];
            if(r2[k][l]!=0)
                r2[k][l]+=r2[k][l+1];
        }
    }
    for(int i=0,k=0;i<m;i++,k++)
    {
        for(int j=1,l=n-2;j<n;j++,l--)
        {
            if(c1[j][i]!=0)
                c1[j][i]+=c1[j-1][i];
            if(c2[l][k]!=0)
                c2[l][k]+=c2[l+1][k];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(draw[i][j]=='*')
            {
                int SIZE=check(i,j);
                if(SIZE)
                {
                    store.pb({i,j});
                    stars[i][j]=SIZE;
                }
            }
        }
    }
    bool flag=true;
    int StoreSize=store.size();
    int posSIZE=pos.size();

    for(int i=0;i<posSIZE;i++)
    {

        int count=0;
        for(int j=0;j<StoreSize;j++)
        {

            int X=store[j].first;
            int Y=store[j].second;
            int SIZE=stars[X][Y];

            if  ((pos[i].first==X && pos[i].second>= (Y-SIZE) && pos[i].second<=(Y+SIZE)) ||
                 (pos[i].second==Y && pos[i].first>= (X-SIZE) && pos[i].first<=(X+SIZE)))
            {

            }
            else
                count++;
        }
        if(count==StoreSize)
        {
            flag=false;
            break;
        }
    }
    if(flag)
    {
        pf("%d\n",StoreSize);
        for(int i=0;i<StoreSize;i++)
            pf("%d %d %d\n",store[i].first+1,store[i].second+1,stars[store[i].first][store[i].second]);
    }
    else
        pf("-1\n");
}