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.
import java.io.*;
import java.util.*;

public class CodeForces {
    /****************************************WRITE CODE HERE **********************************************/
    private static void solve() {
        int n = sc.nextInt();
        int m = sc.nextInt();
        char[][] grid = sc.set2DCharArray(n,m);
        int[][] rowPrefix = new int[n][m];
        int[][] colPrefix = new int[n][m];
        int[][] rowSuffix = new int[n][m];
        int[][] colSuffix = new int[n][m];

        for(int row = 0;row<n;row++){
            rowPrefix[row][0] = grid[row][0]=='*'?1:0;
            for(int col=1;col<m;col++){
                if(grid[row][col]=='.')rowPrefix[row][col] = 0;
                else rowPrefix[row][col] = 1+rowPrefix[row][col-1];
            }
            rowSuffix[row][m-1] = grid[row][m-1]=='*'?1:0;
            for(int col=m-2;col>=0;col--){
                if(grid[row][col]=='.')rowSuffix[row][col] = 0;
                else rowSuffix[row][col] = 1+rowSuffix[row][col+1];
            }
        }
        for(int col = 0;col<m;col++) {
            colPrefix[0][col]  = grid[0][col]=='*'?1:0;
            for(int row = 1;row<n;row++)
                if(grid[row][col]=='.')colPrefix[row][col] = 0;
                else colPrefix[row][col] = 1 + colPrefix[row-1][col];
            colSuffix[n-1][col]     =  grid[n-1][col]=='*'?1:0;
            for(int row = n-2;row>=0;row--){
                if(grid[row][col]=='.')colSuffix[row][col] = 0;
                else colSuffix[row][col] = 1 + colSuffix[row+1][col];
            }
        }
        List<int[]> ans = new ArrayList<>();
        for(int row = 0;row<n;row++)
            for(int col = 0;col<m;col++){
                if(grid[row][col]=='.')continue;;
                int left = rowPrefix[row][col];
                int right = rowSuffix[row][col];
                int up = colPrefix[row][col];
                int down = colSuffix[row][col];
                int len = min2(min2(left,right),min2(up,down));
                if(len>1){
                    ans.add(new int[]{row+1,col+1,len-1});
                }
            }
        for(int[] ele : ans){
            int len = ele[2];
            int row = ele[0]-1;
            int col = ele[1] -1;
            for(int r = (row - len); r<=(row+len);r++)
                grid[r][col] = '.';
            for(int c = (col - len); c<=col+len;c++)
                grid[row][c] = '.';
        }
        boolean isPossible = true;
        for(int row = 0; row<n;row++)
            for(int col = 0;col<m;col++)
                if(grid[row][col]=='*')isPossible = false;

        for(int row = 0; row<n;row++){
            for(int col = 0;col<m;col++)debug.print(grid[row][col]+" ");
            debug.println();
        }
        if(!isPossible){
            out.println(-1);
            return;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(ans.size()).append('\n');
        for(int [] ele : ans)
            sb.append(ele[0]).append(" ").append(ele[1]).append(" ").append(ele[2]).append("\n");
        out.print(sb);
    }


    /*****************************************WRITING CODE ENDS HERE******************************************/

    public static void main(String[] args){
        FIO();
        int testCase = 1;
//        testCase = sc.nextInt();
        while (testCase-- > 0) solve();
        closeIO();
    }

    static Scanner sc ;                     // FAST INPUT
    static PrintWriter out;                // FAST OUTPUT
    static PrintWriter debug ;             // DEBUG IN FILE : debug.txt

    public static void FIO(){
        sc = new Scanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        try {
            debug = new PrintWriter(new FileOutputStream("debug.txt"));
        }catch (IOException e){
            e.printStackTrace();
        }
    }
    public static void closeIO(){
        sc.close();
        out.flush();
        out.close();
        debug.flush();
        debug.close();
    }


    /**************************************HELPER FUNCTION STARTS HERE ************************************/

    public static int mod = (int) 1e9 + 7;
    public static final int INT_MAX = Integer.MAX_VALUE;
    public static final int INT_MIN = Integer.MIN_VALUE;
    public static final long LONG_MAX = Long.MAX_VALUE;
    public static final long LONG_MIN = Long.MIN_VALUE;
    public static final double DOUBLE_MAX = Double.MAX_VALUE;
    public static final double DOUBLE_MIN = Double.MIN_VALUE;
    public static final String YES = "YES";
    public static final String NO = "NO";

    public static void sort(int[] a, boolean isAscending) {
        ArrayList<Integer> temp = new ArrayList<>();
        for (int j : a) temp.add(j);
        sort(temp, isAscending);
        for (int i = 0; i < a.length; i++) a[i] = temp.get(i);
    }

    public static void sort(long[] a, boolean isAscending) {
        ArrayList<Long> temp = new ArrayList<>();
        for (long ele : a) temp.add(ele);
        sort(temp, isAscending);
        for (int i = 0; i < a.length; i++) a[i] = temp.get(i);
    }

    public static void sort(List list, boolean isAscending) {
        if (isAscending)
            Collections.sort(list);
        else Collections.sort(list, Collections.reverseOrder());
    }

    // euclidean algorithm
    public static long gcd(long a, long b) {
        // time O(max (loga ,logb))
        long x = Math.min(a, b);
        long y = Math.max(a, b);
        if (y % x == 0) return x;
        return gcd(y % x, x);
    }

    public static long lcm(long a, long b) {
        // lcm(a,b) * gcd(a,b) = a * b
        return (a / gcd(a, b)) * b;
    }

    public static long power(long x, long n) {
        // time O(logn)
        long ans = 1;
        while (n > 0) {
            if ((n & 1) == 1) {
                ans *= x;
                ans %= mod;
                n--;
            } else {
                x *= x;
                x %= mod;
                n >>= 1;
            }
        }
        return ans;
    }

    public static long factorial(long n) {
        long fact = 1L;
        for (int i = 2; i <= n; i++) fact = (fact * i) % mod;
        return fact;
    }

    public static long firstDivisor(long n) {
        if (n == 1) return n;
        for (long i = 2; i * i <= n; i++)
            if (n % i == 0) return i;
        return -1;
    }

    public static int ncr(int n, int r) {
        // time O(n+r)
        if (r > n)
            return 0;
        long[] inv = new long[r + 1];
        inv[1] = 1;
        // Getting the modular inversion
        // for all the numbers
        // from 2 to r with respect to m
        for (int i = 2; i <= r; i++) {
            inv[i] = mod - (mod / i) * inv[mod % i] % mod;
        }
        int ans = 1;
        // for 1/(r!) part
        for (int i = 2; i <= r; i++) {
            ans = (int) (((ans % mod) * (inv[i] % mod)) % mod);
        }
        // for (n)*(n-1)*(n-2)*...*(n-r+1) part
        for (int i = n; i >= (n - r + 1); i--) {
            ans = (int) (((ans % mod) * (i % mod)) % mod);
        }
        return ans;
    }

    public static long max3(long a, long b, long c) { return max2(max2(a, b), c);}

    public static long max2(long a, long b) {return Math.max(a, b);}

    public static long min3(long a, long b, long c) {return min2(min2(a, b), c);}

    public static long min2(long a, long b) { return Math.min(a, b); }

    public static int max3(int a, int b, int c) { return max2(max2(a, b), c); }

    public static int max2(int a, int b) { return Math.max(a, b); }

    public static int min3(int a, int b, int c) { return min2(min2(a, b), c); }

    public static int min2(int a, int b) {
        return Math.min(a, b);
    }

    /**************************************HELPER FUNCTION ENDS HERE ************************************/

    /*****************************************FAST INPUT STARTS HERE *************************************/


    private static class Scanner {
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer st = new StringTokenizer("");

        public String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();

        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] setintArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) arr[i] = nextInt();
            return arr;
        }

        public long[] setlongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) arr[i] = nextLong();
            return arr;
        }

        public int[][] set2DIntArray(int n) {
            return set2DIntArray(n, n);
        }

        public int[][] set2DIntArray(int row, int col) {
            int[][] arr = new int[row][col];
            for (int i = 0; i < row; i++)
                for (int j = 0; j < col; j++)
                    arr[i][j] = nextInt();
            return arr;
        }

        public long[][] set2DlongArray(int n) {
            return set2DlongArray(n, n);
        }

        public long[][] set2DlongArray(int row, int col) {
            long[][] arr = new long[row][col];
            for (int i = 0; i < row; i++)
                for (int j = 0; j < col; j++)
                    arr[i][j] = nextLong();
            return arr;
        }

        public char[][] set2DCharArray(int n) {
            return set2DCharArray(n, n);
        }

        public char[][] set2DCharArray(int row, int col) {
            char[][] ch = new char[row][col];
            for (int i = 0; i < row; i++)
                ch[i] = sc.next().toCharArray();
            return ch;
        }

        public void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    /*****************************************FAST INPUT ENDS HERE *************************************/
}
