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 \times 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 \cdot 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 \cdot m$ stars.


-----Input-----

The first line of the input contains two integers $n$ and $m$ ($3 \le n, m \le 100$) — 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 \le k \le n \cdot 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.

Difficulty: introductory

Starter code:

Solutions:
n, m = map(int, input().split())
pole = []
metka = []
for i in range(n):
    pole.append([])
    metka.append([])
    s = input()
    for j in range(m):
        pole[i].append(s[j])
        if s[j] == '.':
            metka[i].append(0)
        else:
            metka[i].append(1)
k = 0
ans = []

for i in range(n):
    for j in range(m):
        if pole[i][j] == '*':
            e = 0
            while i - e - 1>= 0 and j - e - 1>= 0 and i + e + 1 < n and j + e + 1< m and pole[i - e - 1][j] == '*' and pole[i][j - e - 1] == '*' and pole[i + e + 1][j] == '*' and pole[i][j + e + 1] == '*':
                e = e + 1
                metka[i][j] = 0
                metka[i - e][j] = 0
                metka[i][j - e] = 0
                metka[i + e][j] = 0
                metka[i][j + e] = 0
            if e != 0:
                k = k + 1
                ans.append((i + 1,j + 1, e))
flag = True
for i in range(n):
    if 1 in metka[i]:
        flag = False
        break
if not flag:
    print(-1)
else:
    print(k)
    for i in range(k):
        print(ans[i][0], ans[i][1], ans[i][2], end='\n')

n, m = map(int,input().split())
table = [[0]*(m+2)]
for i in range(n):
    table.append([0])
    s = input()
    for j in range(m):
        table[i+1].append(2 if s[j]=='*' else 0)
    table[i+1].append(0)
table.append([0]*(m+2))
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
answer = []
for i in range(1, n+1):
    for j in range(1, m+1):
        if table[i][j] == 0:
            continue
        able = True
        size = 0
        while able:
            size += 1
            for k in range(4):
                if table[i + dx[k]*size][j + dy[k]*size] == 0:
                    able = False
        size -= 1
        if size > 0:
            table[i][j] = 1
            for k in range(1, size+1):
                for q in range(4):
                    table[i + dx[q]*k][j + dy[q]*k] = 1
            answer.append([i, j, size])
Ok = True
for i in range(1, n+1):
    for j in range(1, m+1):
        if table[i][j] == 2:
            Ok = False
if not Ok:
    print(-1)
else:
    print(len(answer))
    for i in answer:
        print(*i)

n, m = list(map(int, input().split()))
used = [[True] * m for i in range(n)]
Pole = [0] * n
M = []
for i in range(n):
    Pole[i] = list(input())
for i in range(n):
    for g in range(m):
        if Pole[i][g] == '*':
            k = 0
            while i - k - 1 >= 0 and i + k + 1 < n and g - k - 1 >= 0 and g + k + 1 < m:
                if Pole[i - k - 1][g] == '*' and Pole[i + k + 1][g] == '*' and Pole[i][g - k - 1] == '*' and Pole[i][g + k + 1] == '*':
                    used[i - k - 1][g] = False
                    used[i + k + 1][g] = False
                    used[i][g - k - 1] = False
                    used[i][g + k + 1] = False
                    k += 1
                    continue
                break
            if k != 0:
                used[i][g] = False
                M.append([i + 1, g + 1, k])
for i in range(n):
    for g in range(m):
        if Pole[i][g] == '*':
            if used[i][g]:
                print(-1)
                break
    else:
        continue
    break
else:
    print(len(M))
    for i in range(len(M)):
        print(*M[i])
                
                


n, m = map(int, input().split())
num = []
used = []
for i in range(n):
    num.append(input())
    used.append([False] * m)
ans = []
for i in range(1, n - 1):
    for j in range(1, m - 1):
        if num[i][j] == '*':
            d1 = 0
            d2 = 0
            d3 = 0
            d4 = 0
            for x in range(j + 1, m):
                if num[i][x] == '.':
                    d1 = x - j - 1
                    break
            else:
                d1 = m - j - 1
            for x in range(j - 1, -1, -1):
                if num[i][x] == '.':
                    d2 = abs(j - x - 1)
                    break
            else:
                d2 = j
            for y in range(i + 1, n):
                if num[y][j] == '.':
                    d3 = y - i - 1
                    break
            else:
                d3 = n - i - 1
            for y in range(i - 1, -1, -1):
                if num[y][j] == '.':
                    d4 = abs(i - y - 1)
                    break
            else:
                d4 = i
            dist = min(d1, d2, d3, d4)
            if dist != 0:
                ans.append([i + 1, j + 1, dist])
                for x in range(j - dist, j + dist + 1):
                    used[i][x] = True
                for y in range(i - dist, i + dist + 1):
                    used[y][j] = True
fl = True
for i in range(n):
    for j in range(m):
        if num[i][j] == '*' and not used[i][j]:
            fl = False
if not fl:
    print(-1)
else:
    print(len(ans))
    for i in range(len(ans)):
        print(*ans[i])

n, m = [int(i) for i in input().split()]
stars = []
directionx = [0, -1, 0, 1]
directiony = [1, 0, -1, 0]
for i in range(n):
    stars.append(list(input()))

s = 0
f = [[False] * m for i in range(n)]
for i in range(n):
    for j in range(m):
        if stars[i][j] == "*":
            s += 1

anslist = []
ans = 0
for i in range(1, n - 1):
    for j in range(1, m - 1):
        if (stars[i][j] == "*") and (stars[i][j - 1] == "*") and (stars[i - 1][j] == "*") and (stars[i][j + 1] == "*") and (stars[i + 1][j] == "*"):
            wkf = True
            count = 0
            while wkf:
                for k in range(4):
                    f[i + directionx[k] * count][j + directiony[k] * count] = True
                count += 1
                for k in range(4):
                    if i + directionx[k] * count >= n:
                        wkf = False
                        break
                    if j + directiony[k] * count >= m:
                        wkf = False
                        break
                    if i + directionx[k] * count < 0:
                        wkf = False
                        break
                    if j + directiony[k] * count < 0:
                        wkf = False
                        break
                    if stars[i + directionx[k] * count][j + directiony[k] * count] != "*":
                        wkf = False
                        break
            anslist.append([i + 1, j + 1, count - 1])
            ans += 1
if sum([sum(f[i]) for i in range(n)]) == s:
    print(ans)
    for i in range(ans):
        for j in anslist[i]:
            print(j, end = " ")
        print()
else:
    print("-1")





n, m = list(map(int, input().split()))
arr = [input() for i in range(n)]
s1 = set()
s2 = set()
res = list()
for i in range(n):
    for j in range(m):
        if arr[i][j] == '*':
            s1.add((i, j))
            l = 1
            while True:
                if i - l >= 0 and i + l < n and j - l >= 0 and j + l < m:
                    if arr[i - l][j] == arr[i + l][j] == arr[i][j - l] == arr[i][j + l] == '*':
                        s2 |= {(i - l, j), (i + l, j), (i, j - l), (i, j + l)}
                        l += 1
                    else:
                        break
                else:
                    break
            l -= 1
            if l > 0:
                s2.add((i, j))
                res.append([i + 1, j + 1, l])
if len(s1 - s2) > 0:
    print(-1)
else:
    print(len(res))
    for x in res:
        print(*x)


n, m  = list(map(int, input().split()))
pole = []
unfitted = []

def star_fits(x,y,r):

    if x-r >=0 and x+r<m and y-r>=0 and y+r <n:
        res = True
        for k in range(x - r, x + r + 1):
            if pole[y][k] != '*':
                res = False
        for k in range(y - r, y + r + 1):
            if pole[k][x] != '*':
                res = False
    else:
        return False
    return res

def get_max_r(x,y):
    r=1
    while (x-r >= 0) and (x+r < m) and (y-r >= 0) and (y+r < n):
        if pole[y][x+r] == '*' and  pole[y][x-r] == '*' and pole[y+r][x] == '*' and  pole[y-r][x] == '*':
            r+=1
        else:
            return r-1
    return r-1


def mark_star(x,y,r):
    if x-r >= 0 and x+r < m and y-r >= 0 and y+r <n:
        for k in range(x - r, x + r + 1):
            unfitted[y][k] = False
        for k in range(y - r, y + r + 1):
            unfitted[k][x] = False


for i in range(n):
    pole.append(input().strip()[:m])
    unfitted.append([True]*m)

fin_res  =[]
for x in range(m):
    for y in range(n):
        if pole[y][x] == '*':
            r = get_max_r(x,y)
            if r>0:
                mark_star(x,y,r)
                # print('found atar at', x,y,r)
                fin_res.append((y+1,x+1,r))


for x in range(m):
    for y in range(n):
        if pole[y][x] == '*' and unfitted[y][x]:
            print(-1)
            return

print(len(fin_res))
for t in fin_res:
    print(*t)







# import logging


# fmt = r'%(levelname)s - %(name)s (line:%(lineno)s) - %(message)s'
# formatter = logging.Formatter(fmt)

# ch = logging.StreamHandler()
# ch.setLevel(logging.ERROR)
# ch.setFormatter(formatter)

# logger = logging.getLogger()
# logger.setLevel(logging.ERROR)
# logger.addHandler(ch)


class StarCell:
    def __init__(self, row, col, top=None, bot=None, left=None, right=None):
        self.row = row
        self.col = col

        self.covered = False

        self.top = top
        self.bot = bot
        self.left = left
        self.right = right

        self._size = None
        self._size_top = None
        self._size_bot = None
        self._size_left = None
        self._size_right = None
    

    def set_adjacents(self, cells):
        row, col = self.row, self.col
        self.top = cells.get((row - 1, col), None)
        self.bot = cells.get((row + 1, col), None)
        self.left = cells.get((row, col - 1), None)
        self.right = cells.get((row, col + 1), None)

    def set_covered(self):
        size = self.size
        ctop = self
        cbot = self
        cleft = self
        cright = self
        for _ in range(size):
            ctop = ctop.top
            cbot = cbot.bot
            cleft = cleft.left
            cright = cright.right
            ctop.covered = True
            cbot.covered = True
            cleft.covered = True
            cright.covered = True

    @property
    def size_top(self):
        if not self.top:
            return 0
        if not self._size_top:
            # Update cache
            self._size_top = 1 + self.top.size_top
        return self._size_top
    
    @property
    def size_bot(self):
        if not self.bot:
            return 0
        if not self._size_bot:
            self._size_bot = 1 + self.bot.size_bot
        return self._size_bot
    
    @property
    def size_left(self):
        if not self.left:
            return 0
        if not self._size_left:
            self._size_left = 1 + self.left.size_left
        return self._size_left
    
    @property
    def size_right(self):
        if not self.right:
            return 0
        if not self._size_right:
            self._size_right = 1 + self.right.size_right
        return self._size_right
    
    @property
    def size(self):
        if not self._size:
            self._size = min(
                [self.size_top,
                self.size_bot,
                self.size_left,
                self.size_right])
        return self._size
    
    def __repr__(self):
        if self.size > 0:
            return 'Star of max size {}'.format(self.size)
        return 'Cell covered? {}'.format(self.covered)


def solve(grid):
    n, m = len(grid), len(grid[0])
    
    cells = {}
    for row in range(n):
        for col in range(m):
            if grid[row][col] == '.':
                continue
            cells[(row, col)] = StarCell(row, col)
    
    for key, val in list(cells.items()):
        val.set_adjacents(cells)

    for key, val in list(cells.items()):
        val.set_covered()

    # for key, val in cells.items():
    #     print(key, val)


    ans = []
    for key, val in list(cells.items()):
        if val.size == 0 and not val.covered:
            return None
        if val.size > 0:
            ans.append([val.row + 1, val.col + 1, val.size])  # Rebase index 1
    return ans


def main():
    n, m = list(map(int, input().strip().split()))
    grid = [list(input().strip()) for _ in range(n)]

    results = solve(grid)
    if results is None:
        print('-1')
    else:
        print(len(results))
        for result in results:
            print(*result)


def __starting_point():
    main()

__starting_point()

n, m = input().split()
n = int(n)
m = int(m)
lst = [[0]*m for i in range(n)]
rec = [[0]*m for i in range(n)]
fin = [[0]*m for i in range(n)]
ans = 0
cnt = 0
for i in range(n):
    tmp = input()
    for j, x in enumerate(tmp):
        if x == '*':
            lst[i][j] = 1
for i in range(n):
    for j in range(m):
        if lst[i][j] == 1 and i > 0 and j > 0 and i < n-1 and j < m-1:
            tmp = min(i, j, n-1-i, m-1-j)
            for k in range(tmp, 0, -1):
                flag = True
                for x in range(1, k+1):
                    if lst[i][j-x] == 0 or lst[i][j+x] == 0 or lst[i-x][j] == 0 or lst[i+x][j] == 0:
                        flag = False
                if flag:
                    fin[i][j] = k
                    break
for i in range(n):
    for j in range(m):
        if fin[i][j] > 0:
            tmp = fin[i][j]
            ans += 1
            cnt += 1 + tmp * 4
            rec[i][j] = 1
            for x in range(tmp+1):
                rec[i][j+x] = 1
                rec[i][j-x] = 1
                rec[i-x][j] = 1
                rec[i+x][j] = 1
if rec != lst:
    print(-1)
else:
    print(ans)
    for i in range(n):
        for j in range(m):
            if fin[i][j] > 0:
                print(i+1, j+1, fin[i][j])


n, m = map(int, input().split())
T = [[] for i in range(n)]
for i in range(n):
    a = list(input())
    T[i] = a

S = [[0] * m for i in range(n)]
for i in range(n):
    for j in range(m):
        if T[i][j] == "*":
            S[i][j] = 1

rec = []
for i in range(n):
    for j in range(m):
        if 1 <= i < n - 1 and 1 <= j < m - 1 and T[i][j] == "*" and T[i - 1][j] == "*" and T[i][j - 1] == "*" and T[i + 1][j] == "*" and T[i][j + 1] == "*":
            S[i][j] = 0
            S[i - 1][j] = 0
            S[i][j - 1] = 0
            S[i + 1][j] = 0
            S[i][j + 1] = 0
            k = 2
            while True:
                if not (0 <= i - k and i + k < n and 0 <= j - k and j + k < m):
                    break
                if T[i - k][j] == "*" and T[i][j - k] == "*" and T[i + k][j] == "*" and T[i][j + k] == "*":
                    S[i - k][j] = 0
                    S[i][j - k] = 0
                    S[i + k][j] = 0
                    S[i][j + k] = 0
                    k += 1
                else:
                    break
            rec.append((i + 1, j + 1, k - 1))

q = 0
for i in range(n):
    for j in range(m):
        q += S[i][j]

if q == 0:
    print(len(rec))
    for i in range(len(rec)):
        print("{} {} {}".format(rec[i][0], rec[i][1], rec[i][2]))
else:
    print(-1)

def all_true(stars, n, m):
    for i in range(n):
        for j in range(m):
            if not stars[i][j]:
                return False
    return True

def get_biggest_star(ar, i, j):
    ans = 0
    cur = i - 1
    while cur >= 0 and ar[cur][j] == '*':
        ans += 1
        cur -= 1

    length = 0
    cur = i + 1
    while cur < n and ar[cur][j] == '*':
        length += 1
        cur += 1
    ans = min(ans, length)

    length = 0
    cur = j - 1
    while cur >= 0 and ar[i][cur] == '*':
        length += 1
        cur -= 1
    ans = min(ans, length)

    length = 0
    cur = j + 1
    while cur < m and ar[i][cur] == '*':
        length += 1
        cur += 1
    ans = min(ans, length)

    return ans

n, m = list(map(int, input().split()))

ar = []

stars = []

for i in range(n):
    cur = input()
    st = []
    for i in range(m):
        if cur[i] == '.': st.append(True)
        else: st.append(False)
    stars.append(st)
    ar.append(cur)

finalAns = []
ans = 0
for i in range(1, n - 1):
    for j in range(1, m - 1):
        if ar[i][j] == '.': continue
        length = get_biggest_star(ar, i, j)
        if length > 0:
            ans += 1
            finalAns.append([i+1, j+1, length])
            stars[i][j] = True
            temp = 0
            while temp < length:
                temp += 1
                stars[i-temp][j] = True
            temp = 0
            while temp < length:
                temp += 1
                stars[i+temp][j] = True
            temp = 0
            while temp < length:
                temp += 1
                stars[i][j-temp] = True
            temp = 0
            while temp < length:
                temp += 1
                stars[i][j+temp] = True

##print(*stars, sep = '\n')

if all_true(stars, n, m):
    print(ans)
    for i in finalAns:
        print(*i)
else:
    print(-1)
            


def main():
	inp = []
	n, m = list(map(int, input().split()))
	remaining = 0
	for _ in range(n):
		cur_inp = input()
		inp.append(cur_inp)
		remaining += cur_inp.count("*")
	remaining2 = [[True]*m for _ in range(n)]
	res = []
	for x in range(1, n-1):
		for y in range(1, m-1):
			if inp[x][y] == "*":
				last_size = None
				for size in range(1, min(x+1, n-x, y+1, m-y)):
					if inp[x-size][y] == inp[x+size][y] == inp[x][y-size] == inp[x][y+size] == "*":
						for x1, y1 in (x-size, y), (x+size, y), (x, y-size), (x, y+size):
							if remaining2[x1][y1]:
								remaining -= 1
								remaining2[x1][y1] = False
						last_size = size
					else:
						break
				if last_size is not None:
					if remaining2[x][y]:
						remaining -= 1
						remaining2[x][y] = False
					res.append((x+1, y+1, last_size))
	if remaining:
		print('-1')
	else:
		print(len(res))
		for x in res:
			print(*x)
main()



import sys
import math
import os.path
from copy import deepcopy
from functools import reduce
from pprint import pprint

from collections import Counter, ChainMap, defaultdict
from itertools import cycle, chain
from queue import Queue, PriorityQueue, deque
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, nlargest, nsmallest
import bisect

from statistics import mean, mode, median, median_low, median_high


# CONFIG
sys.setrecursionlimit(10**9)

# LOG 
def log(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


# INPUT
def ni():
    return list(map(int, input().split()))


def nio(offset):
    return [int(x) + offset for x in input().split()]


def nia():
    return list(map(int, input().split()))


# CONVERT
def toString(aList, sep=" "):
    return sep.join(str(x) for x in aList)


def toMapInvertIndex(aList):
    return {k: v for v, k in enumerate(aList)}


# SORT
def sortId(arr):
    return sorted(list(range(len(arr))), key=lambda k: arr[k])


# MAIN

n,m = ni()

s = [0]*n

for i in range(n):
    ss = input()
    s[i] = ss

dd = [['.' for j in range(m)] for i in range(n)]

# pprint(s)
# pprint(dd)

res = deque()
for i in range(n):
    for j in range(m):
        if s[i][j] == '*':            
            # print(i,j)
            k = 1
            while 0 <= i - k < n and 0 <= i + k < n and 0 <= j - k < m and 0 <= j + k < m and s[i-k][j] == "*" and s[i+k][j] == "*" and s[i][j-k] == "*" and s[i][j+k] == "*":
                dd[i-k][j] = "*"
                dd[i+k][j] = "*"
                dd[i][j-k] = "*"
                dd[i][j+k] = "*"
                if k == 1:
                    dd[i][j] = "*"
                    res.append((i+1, j+1, k))
                else:
                    res[-1] = (i+1, j+1, k)
                # print(i,j,k)
                k+=1

# pprint(dd)

def check():
    for i in range(n):
        for j in range(m):
            if s[i][j] != dd[i][j]:
                return False
    return True

if check():
    lres = len(res)
    print(lres)
    if (lres > 0):
        print("\n".join((" ".join(str(y) for y in x)) for x in res))
else:
    print(-1)


N,M=list(map(int,input().split()))
L=[]
for a in range(N):
    L.append(list(input()))
ANS=[]
for i in range(N):
    for j in range(M):
        if(L[i][j]=='*' or L[i][j]=='-'):
            k=1
            l=min(i,j,(N-1-i),(M-1-j))
            while(k<=l):
                if((L[i+k][j]=='*' or L[i+k][j]=='-') and (L[i][j+k]=='*' or L[i][j+k]=='-') and (L[i-k][j]=='*' or L[i-k][j]=='-') and (L[i][j-k]=='*' or L[i][j-k]=='-')):
                    L[i][j]='-'
                    L[i+k][j]='-'
                    L[i-k][j]='-'
                    L[i][j+k]='-'
                    L[i][j-k]='-'
                    k+=1
                else:
                    break
            if(k>1):
                ANS.append((i+1,j+1,k-1))
f=True
for a in L:
    if('*' in a):
        f=False
        break
if(f):
    print(len(ANS))
    for a in ANS:
        print(' '.join(map(str,a)))
else:
    print(-1)


n,m=map(int,input().split())
g=[[*input()] for _ in range(n)]
c=[[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
 v=0
 for j in range(m):
  v=(v+1)*(g[i][j]=='*')
  c[i][j]=v
 v=0
 for j in range(m-1,-1,-1):
  v=(v+1)*(g[i][j]=='*')
  c[i][j]=min(c[i][j],v)
for j in range(m):
 v=0
 for i in range(n):
  v=(v+1)*(g[i][j]=='*')
  c[i][j]=min(c[i][j],v)
 v=0
 for i in range(n-1,-1,-1):
  v=(v+1)*(g[i][j]=='*')
  c[i][j]=min(c[i][j],v)
for i in range(n):
 for j in range(m):
  if c[i][j]==1: c[i][j]=0
for i in range(n):
 v=0
 for j in range(m):
  v=max(v-1,c[i][j])
  if v:g[i][j]='.'
 v=0
 for j in range(m-1,-1,-1):
  v=max(v-1,c[i][j])
  if v:g[i][j]='.'
for j in range(m):
 v=0
 for i in range(n):
  v=max(v-1,c[i][j])
  if v:g[i][j]='.'
 for i in range(n-1,-1,-1):
  v=max(v-1,c[i][j])
  if v:g[i][j]='.'
if all(g[i][j]=='.' for i in range(n) for j in range(m)):
 r=[(i+1,j+1,c[i][j]-1) for i in range(n) for j in range(m) if c[i][j]]
 print(len(r))
 for t in r: print(*t)
else:
 print(-1)

import math as ma
from decimal import Decimal as dec


def li():
	return list(map(int , input().split()))


# https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/
def modInverse(a , m):
	m0 = m
	y = 0
	x = 1
	if (m == 1):
		return 0
	while (a > 1):
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if (x < 0):
		x = x + m0
	return x


m = 10000019


def binomialCoefficient(n , k):
	if (k > n - k):
		k = (n - k) % m
	res = 1
	for i in range(k):
		res = (res * (n - i)) % m
		res = (res * modInverse((i + 1) , m)) % m
	return res


def num():
	return map(int , input().split())


def nu():
	return int(input())


def find_gcd(x , y):
	while (y):
		x , y = y , x % y
	return x


n , m = num()
a = [0] * n
b = [0] * n
for i in range(n):
	x = input()
	a[i] = [0] * m
	b[i] = [0] * m
	for j in range(m):
		if (x[j] == "*"):
			a[i][j] = 1
pp=[]
for i in range(n):
	for j in range(m):
		u = 0
		d = 0
		l = 0
		r = 0
		if (a[i][j] == 1):
			for k in range(i - 1 , -1 , -1):
				if (a[k][j] == 1):
					u += 1
				else:
					break
			for k in range(i + 1 , n):
				if (a[k][j] == 1):
					d += 1
				else:
					break
			for k in range(j - 1 , -1 , -1):
				if (a[i][k] == 1):
					l += 1
				else:
					break
			for k in range(j + 1 , m):
				if (a[i][k] == 1):
					r += 1
				else:
					break
			zz = min(u , d , l , r)
			#print(i,j,zz)
			if(zz==0):
				continue
			pp.append((i+1,j+1,zz))
			b[i][j] = 1
			c=0
			for k in range(i - 1 , -1 , -1):
				b[k][j]=1
				c+=1
				if(c==zz):
					break
			c=0
			for k in range(i + 1 , n):
				b[k][j] = 1
				c += 1
				if (c == zz):
					break
			c=0
			for k in range(j - 1 , -1 , -1):
				b[i][k]=1
				c += 1
				if (c == zz):
					break
			c=0
			for k in range(j + 1 , m):
				b[i][k] = 1
				c+=1
				if(c==zz):
					break
fl=True
for i in range(n):
	for j in range(m):
		if(a[i][j]==1 and b[i][j]==0):
			fl=False
			break
if(fl):
	print(len(pp))
	for i in range(len(pp)):
		print(pp[i][0],pp[i][1],pp[i][2])
else:
	print(-1)

def find_stars(h, w, matrix):
    max_size = 0
    if matrix[h][w] == '.':
        return max_size

    size = 1
    while True:
        for next_h in range(h, h + size + 1):
            if next_h >= height or matrix[next_h][w] != '*':
                return max_size
        for next_h in range(h, h - size - 1, -1):
            if next_h < 0 or matrix[next_h][w] != '*':
                return max_size
        for next_w in range(w, w + size + 1):
            if next_w >= width or matrix[h][next_w] != '*':
                return max_size
        for next_w in range(w, w - size - 1, -1):
            if next_w < 0 or matrix[h][next_w] != '*':
                return max_size

        max_size = size
        size += 1


height, width = list(map(int, input().split()))
matrix = []
for h in range(height):
    row = input()
    matrix.append(row)

result_matrix = [['.'] * width for h in range(height)]
result_stars = []
for h in range(height):
    for w in range(width):
        found_max_size = find_stars(h, w, matrix)
        if found_max_size == 0:
            continue

        for next_h in range(h, h + found_max_size + 1):
            result_matrix[next_h][w] = '*'
        for next_h in range(h, h - found_max_size - 1, -1):
            result_matrix[next_h][w] = '*'
        for next_w in range(w, w + found_max_size + 1):
            result_matrix[h][next_w] = '*'
        for next_w in range(w, w - found_max_size - 1, -1):
            result_matrix[h][next_w] = '*'

        result_stars.append(str(h + 1) + ' ' + str(w + 1) + ' ' + str(found_max_size))

is_equal = True
for h in range(height):
    for w in range(width):
        if matrix[h][w] != result_matrix[h][w]:
            is_equal = False

if is_equal:
    print(len(result_stars))
    for star in result_stars:
        print(star)
else:
    print(-1)


n, m = map(int, input().split())
G = []
L = [[0 for x in range(m + 2)] for x in range(n + 2)]
R = [[0 for x in range(m + 2)] for x in range(n + 2)]
U = [[0 for x in range(m + 2)] for x in range(n + 2)]
D = [[0 for x in range(m + 2)] for x in range(n + 2)]

for i in range(n):
    s = input()
    G.append(s)
    
for i in range(n):
    
    nm = 0
    for j in range(m):
        if(G[i][j] == '*'):
            nm += 1
        else:
            nm = 0
        L[i][j] = nm
        
    nm = 0
    for j in range(m - 1, -1, -1):
        if(G[i][j] == '*'):
            nm += 1
        else:
            nm = 0
        R[i][j] = nm
        
for j in range(m):
    
    nm = 0
    for i in range(n):
        if(G[i][j] == '*'):
            nm += 1
        else:
            nm = 0
        U[i][j] = nm
    
    nm = 0
    for i in range(n - 1, -1, -1):
        if(G[i][j] == '*'):
            nm += 1
        else:
            nm = 0
        D[i][j] = nm

col = [[0 for x in range(m + 2)] for x in range(n + 2)]
row = [[0 for x in range(m + 2)] for x in range(n + 2)]
ANS = []

for i in range(n):
    for j in range(m):
        if(G[i][j] == '.'):
            continue
        ans = min(U[i][j], L[i][j], R[i][j], D[i][j]) - 1
        if(ans <= 0):
            continue
        ANS.append([i + 1, j + 1, ans])
        row[i][j - ans] += 1
        row[i][j + ans + 1] -=1
        col[i - ans][j] += 1
        col[i + ans + 1][j] -= 1
        
        
for i in range(n):
    for j in range(1, m):
        row[i][j] += row[i][j - 1]

for j in range(m):
    for i in range(1, n):
        col[i][j] += col[i - 1][j]
        
okay = True
for i in range(n):
    for j in range(m):
        if(G[i][j] == '*' and row[i][j] == 0 and col[i][j] == 0):
            okay = False
            
if(okay):
    print(len(ANS))
    for x in ANS:
        print(x[0], x[1], x[2])
else:
    print(-1)

n, m = map(int, input().split())
sky = [0] * (n + 1)
for i in range(n):
    sky[i] = list(input()) + ['.']
sky[n] = ['.'] * m
used = [[False] * m for i in range(n)]
ans = []
for i in range(n):
    for j in range(m):
        if sky[i][j] == '.':
            continue
        ln = 1
        while sky[i - ln][j] == '*' and sky[i + ln][j] == '*' and sky[i][j - ln] == '*' and sky[i][j + ln] == '*':
            used[i - ln][j] = used[i + ln][j] = used[i][j - ln] = used[i][j + ln] = True
            ln += 1
        if ln > 1:
            used[i][j] = True
            ans += [[i + 1, j + 1, ln - 1]]
for i in range(n):
    for j in range(m):
        if sky[i][j] == '*' and not used[i][j]:
            print(-1)
            return
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])

import sys
n,m=list(map(int,input().split()))
s=[input() for i in range(n)]
dp=[[-1 for i in range(m)] for j in range(n)]
ans=[]
for i in range(1,n-1):
    for j in range(1,m-1):
        if (s[i][j]=='*' and s[i+1][j]=='*' and s[i-1][j]=='*' and s[i][j-1]=='*' and s[i][j+1]=='*'):
            x=0
            while i-x>-1 and x+i<n and j-x>-1 and x+j<m and s[i+x][j]=='*' and s[i-x][j]=='*' and s[i][j-x]=='*' and s[i][j+x]=='*':
                dp[i+x][j],dp[i-x][j],dp[i][j-x],dp[i][j+x]=1,1,1,1
                x+=1
            if x!=1:  ans.append([i+1,j+1,x-1])
            else:dp[i][j]=-1
for i in range(n):
    for j in range(m):
        if s[i][j]=='*' and dp[i][j]==-1:
            print(-1)
            return
print(len(ans))
for i in ans:
    print(*i)


import sys
n,m=list(map(int,input().split()))
s=[input() for i in range(n)]
dp=[[-1 for i in range(m)] for j in range(n)]
ans=[]
for i in range(1,n-1):
    for j in range(1,m-1):
        if (s[i][j]=='*' and s[i+1][j]=='*' and s[i-1][j]=='*' and s[i][j-1]=='*' and s[i][j+1]=='*'):
            x=0
            while i-x>-1 and x+i<n and j-x>-1 and x+j<m and s[i+x][j]=='*' and s[i-x][j]=='*' and s[i][j-x]=='*' and s[i][j+x]=='*':
                dp[i+x][j],dp[i-x][j],dp[i][j-x],dp[i][j+x]=1,1,1,1
                x+=1
            if x!=1:  ans.append([i+1,j+1,x-1])
            else:dp[i][j]=-1
for i in range(n):
    for j in range(m):
        if s[i][j]=='*' and dp[i][j]==-1:
            print(-1)
            return
print(len(ans))
for i in ans:
    print(*i)