#!/usr/bin/python
# -*- coding: utf8 -*-
#
# Задача 'Луна'
# XVIII командный чемпионат школьников Санкт-Петербурга по программированию
# Автор задачи: Юрий Петров
# Автор генератора: Владимир Ульянцев, ulyantsev@rain.ifmo.ru
#
# Простенький генератор без использования сторонних библиотек для генерации

MAXH = 1000
MAXW = 1000
MAXS = 25

handmade = [
    (8, 7, [(1, 0, 0), (6, 7, 0), (3, 3, 3)], 'statement test'),
    (4, 5, [(1, 1, 0), (2, 2, 0)], 'statement test'),
    (1, 1, [(0, 0, 0)], 'mintest'),
    (100, 100, [(12, 16, 10)] + [(12, 26 + i, 0) for i in xrange(25)], 'handmade chupachups'),
    (MAXH, MAXW, [(123, 126, 100)] + [(123, 226 + i, 0) for i in xrange(25)], 'handmade big chupachups'),
]

import random
from random import randint

test_number = 0

def open_output():
    global test_number
    test_number += 1
    num = '%d%d' % divmod(test_number, 10)
    print 'Generating test #' + num
    
    return open(num, 'w')

def print_test(test, desc):
    ouf = open_output()
    print >>ouf, test,
    print >>desc_file, ('%d%d' % divmod(test_number, 10)) + ': ' + desc
    ouf.close()

def circles_to_string(h, w, circles):
    a = [['.' for i in xrange(w)] for j in xrange(h)]
    for x, y, r in circles:
        for i in xrange(x - r, x + r + 1):
            for j in xrange(y - r, y + r + 1):
                if (x - i) * (x - i) + (y - j) * (y - j) <= r * r:
                    a[j][i] = '*'
    test = '%d %d\n' % (w, h)
    test = test + ''.join([''.join([a[i][j] for j in xrange(w)]) + '\n' for i in xrange(h)])
    return test

def hard_moon_to_corner(h, w, r, c):
    ans = [(r + randint(0, 5), r + randint(0, 5), r)]
    for i in xrange(5):
        ans += [(h - 1 - i, w - 1 - j, 0) for j in xrange(5)]
    if c % 2 == 0:
        ans = [(x, h - y - 1, r) for x, y, r in ans]
    if c > 2:
        ans = [(w - x - 1, y, r) for x, y, r in ans]

    return ans

def random_test(h, w, r, cnt):
    x = randint(r, w - r - 1)
    y = randint(r, h - r - 1)
    ans = [(x, y, r)] + [(randint(0, w - 1), randint(0, h - 1), 0) for i in xrange(cnt)]
    return ans

def print_handmade():
    for s in handmade:
        print_test(circles_to_string(s[0], s[1], s[2]), s[3])
        
if __name__ == '__main__':
    random.seed(932239)
    desc_file = open('tests.desc', 'w')

    print_handmade()

    for i in xrange(5):
        h = randint(3, 11)
        w = randint(3, 11)
        r = randint(0, min((h + 1) / 2, (w + 1) / 2) - 1)
        print_test(circles_to_string(h, w, random_test(h, w, r, randint(0, 10))), 'small random test')

    for i in xrange(10):
        h = randint(5, 15)
        w = randint(5, 15)
        r = min((h + 1) / 2, (w + 1) / 2) - 1
        print_test(circles_to_string(h, w, random_test(h, w, r, 25)), 'small random test')


    for i in xrange(10):
        h = randint(11, 20)
        w = randint(11, 20)
        r = randint(0, min(h / 2, w / 2) - 1)
        print_test(circles_to_string(h, w, random_test(h, w, r, randint(2, 20))), 'small random test')

    for i in xrange(20):
        h = randint(MAXH / 10, MAXH)
        w = randint(MAXW / 10, MAXW)
        r = randint(0, min(h / 2, w / 2) - 1)
        print_test(circles_to_string(h, w, random_test(h, w, r, randint(20, 25))), 'big random test')
        
    for r in [10, 20, 25, 30, 40, 50, 75, 100, 200, MAXH / 2 - 1]:
        for c in [1, 2, 3, 4]:
            h = MAXH
            w = MAXW
            print_test(circles_to_string(h, w, hard_moon_to_corner(h, w, r, c)), 'big test with moon in the corner')

    desc_file.close()
