A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).

Let's consider empty cells are denoted by '.', then the following figures are stars:

<image> The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.

You are given a rectangular grid of size n × m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n ⋅ m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.

In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n ⋅ m stars.

Input

The first line of the input contains two integers n and m (3 ≤ n, m ≤ 1000) — the sizes of the given grid.

The next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.

Output

If it is impossible to draw the given grid using stars only, print "-1".

Otherwise in the first line print one integer k (0 ≤ k ≤ n ⋅ m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — x_j, y_j and s_j, where x_j is the row index of the central star character, y_j is the column index of the central star character and s_j is the size of the star. Each star should be completely inside the grid.

Examples

Input

6 8
....*...
...**...
..*****.
...**...
....*...
........


Output

3
3 4 1
3 5 2
3 5 1


Input

5 5
.*...
****.
.****
..**.
.....


Output

3
2 2 1
3 3 1
3 4 1


Input

5 5
.*...
***..
.*...
.*...
.....


Output

-1


Input

3 3
*.*
.*.
*.*


Output

-1

Note

In the first example the output 
    
    
    2  
    3 4 1  
    3 5 2  
    

is also correct.
//package math_codet;

import java.io.*;
import java.util.*;
 /******************************************
*    AUTHOR:         AMAN KUMAR SINGH        *
*    INSTITUITION:   KALYANI GOVERNMENT ENGINEERING COLLEGE  *
******************************************/
public class lets_do {
    InputReader in;
    PrintWriter out;
    Helper_class h;
    final long mod=1000000007;
    final int N=200005;
    public static void main(String[] args) throws java.lang.Exception{
        new lets_do().run();
    }
    void run() throws Exception{
        in=new InputReader(System.in);
        out = new PrintWriter(System.out);
        h = new Helper_class();
        int t=1;
        while(t-->0){
            solve();
        }
        out.flush();    
        out.close();
    }
    TreeMap<Long,Integer> tmap=new TreeMap<Long,Integer>();
    HashMap<Long,Integer> hmap=new HashMap<Long,Integer>();
    int min1(int a, int b, int c, int d){
        return Math.min(a,Math.min(b,Math.min(c,d)));
    }
    void solve(){
    	StringBuffer str=new StringBuffer();
        int n=h.ni();
        int m=h.ni();
        int[][] arr=new int[n][m];
        int i=0,j=0,k=0;
        for(i=0;i<n;i++){
            String st=h.n();
            for(j=0;j<m;j++){
                if(st.charAt(j)=='*')
                    arr[i][j]=1;
                else{
                    arr[i][j]=0;
                }
            }
        }
        int[][] row_left=new int[n][m];
        int[][] row_right=new int[n][m];
        int[][] column_up=new int[n][m];
        int[][] column_down=new int[n][m];
        int[][] row_op=new int[n+1][m+1];
        int[][] column_op=new int[n+1][m+1];
        for(i=0;i<n;i++){
            int sum=0;
            for(j=0;j<m;j++){
                if(arr[i][j]==0)
                    sum=0;
                else
                    sum++;
                row_left[i][j]=sum;
            }
            sum=0;
            for(j=m-1;j>=0;j--){
                if(arr[i][j]==0)
                    sum=0;
                else
                    sum++;
                row_right[i][j]=sum;
            }
        }
        for(i=0;i<m;i++){
            int sum=0;
            for(j=0;j<n;j++){
                if(arr[j][i]==0)
                    sum=0;
                else
                    sum++;
                column_down[j][i]=sum;
            }
            sum=0;
            for(j=n-1;j>=0;j--){
                if(arr[j][i]==0)
                    sum=0;
                else
                    sum++;
                column_up[j][i]=sum;
            }
        }
        int count=0;
        for(i=1;i<n-1;i++){
            for(j=1;j<m-1;j++){
                if(arr[i][j]==1){
                    int min=min1(column_down[i-1][j],column_up[i+1][j],row_left[i][j-1],row_right[i][j+1]);
                    //h.pn(i+" "+j+" "+min);
                    if(min>0){
                        row_op[i][j-min]++;
                        row_op[i][j]--;
                        row_op[i][j+1]++;
                        row_op[i][j+min+1]--;
                        column_op[i-min][j]++;
                        column_op[i][j]--;
                        column_op[i+1][j]++;
                        column_op[i+min+1][j]--;
                        row_op[i][j]++;
                        row_op[i][j+1]--;
                        column_op[i][j]++;
                        column_op[i+1][j]--;
                        count++;
                        str.append((i+1)+" "+(j+1)+" "+min).append("\n");
                    }
                }
            }
        }
        int[][] row_sum=new int[n+1][m+1];
        int[][] column_sum=new int[n+1][m+1];
        for(i=0;i<n;i++){
            int sum=0;
            for(j=0;j<m;j++){
                sum+=row_op[i][j];
                row_sum[i][j]=sum;
            }
        }
        for(i=0;i<m;i++){
            int sum=0;
            for(j=0;j<n;j++){
                sum+=column_op[j][i];
                column_sum[j][i]=sum;
            }
        }
        boolean ok=true;
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                if(column_sum[i][j]<=0 && row_sum[i][j]<=0 && arr[i][j]==1)
                    ok=false;
            }
        }
        if(!ok)
            h.pn(-1);
        else{
            h.pn(count);
            h.pn(str);
        }
    }
    static final Comparator<Entity> com2=new Comparator<Entity>(){
        public int compare(Entity x, Entity y){
            int xx=Long.compare(x.a,y.a);
            if(xx==0)
                return Long.compare(x.b,y.b);
            else
                return xx;
        }
    };
    class Entity{
        long a;
        long b;
        Entity(long p, long q){
            a=p;
            b=q;
        }
    }
    

    class Helper_class{
        long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
        int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
        long gcd1(long a, long b){return (b==0)?a:gcd(b,a%b);}
        int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
        void p(Object o){out.print(o);}
        void pn(Object o){out.println(o);}
        void pni(Object o){out.println(o);out.flush();}
        String n(){return in.next();}
        String nln(){return in.nextLine();}
        int ni(){return in.nextInt();}
        long nl(){return in.nextLong();}
        double nd(){return in.nextDouble();}

        long mul(long a,long b){
            if(a>=mod)a%=mod;
            if(b>=mod)b%=mod;
            a*=b;
            if(a>=mod)a%=mod;
            return a;
        }
        long modPow(long a, long p){
            long o = 1;
            while(p>0){
                if((p&1)==1)o = mul(o,a);
                a = mul(a,a);
                p>>=1;
            }
            return o;
        }
        long add(long a, long b){
            if(a>=mod)a%=mod;
            if(b>=mod)b%=mod;
            if(b<0)b+=mod;
            a+=b;
            if(a>=mod)a-=mod;
            return a;
        }
    }

    class InputReader{
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
 
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
 
        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
 
        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }
 
        public void skip(int x) {
            while (x-- > 0)
                read();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
 
        public String nextString() {
            return next();
        }
 
        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
 
            return res.toString();
        }
 
        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }
 
        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
 
        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }
 
        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}