Problem:
 Score : 500 points    Problem Statement You are given two integers A and B .  Print a grid where each square is painted white or black that satisfies the following conditions, in the format specified in Output section:   Let the size of the grid be h \times w ( h vertical, w horizontal). Both h and w are at most 100 .  The set of the squares painted white is divided into exactly A connected components.  The set of the squares painted black is divided into exactly B connected components.   It can be proved that there always exist one or more solutions under the conditions specified in Constraints section.
If there are multiple solutions, any of them may be printed.      Notes Two squares painted white, c_1 and c_2 , are called connected when the square c_2 can be reached from the square c_1 passing only white squares by repeatedly moving up, down, left or right to an adjacent square.  A set of squares painted white, S , forms a connected component when the following conditions are met:   Any two squares in S are connected.  No pair of a square painted white that is not included in S and a square included in S is connected.   A connected component of squares painted black is defined similarly.      Constraints  1 \leq A \leq 500  1 \leq B \leq 500         Input Input is given from Standard Input in the following format:  A  B       Output Output should be in the following format:   In the first line, print integers h and w representing the size of the grid you constructed, with a space in between.  Then, print h more lines. The i -th ( 1 \leq i \leq h ) of these lines should contain a string s_i as follows:  If the square at the i -th row and j -th column ( 1 \leq j \leq w ) in the grid is painted white, the j -th character in s_i should be . .  If the square at the i -th row and j -th column ( 1 \leq j \leq w ) in the grid is painted black, the j -th character in s_i should be # .           Sample Input 1 2 3      Sample Output 1 3 3
##.
..#
#.#  This output corresponds to the grid below:          Sample Input 2 7 8      Sample Output 2 3 5
#.#.#
.#.#.
#.#.#       Sample Input 3 1 1      Sample Output 3 4 2
..
#.
##
##       Sample Input 4 3 14      Sample Output 4 8 18
..................
..................
....##.......####.
....#.#.....#.....
...#...#....#.....
..#.###.#...#.....
.#.......#..#.....
#.........#..####.

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache





MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b: a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





A,B = IL()
print(100,100)
A =["
B =["
for j in range(25):
  for i in range(50):
    print(A.pop(),end="")
    if i == 49:
      print("
    else:
      print("
  print("
for j in range(25):
  print("."*100)
  for i in range(50):
    print(B.pop(),end="")
    if i == 49:
      print(".")
    else:
      print(".",end="")

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    A, B = [int(x) for x in input().split()]

    C = []
    for i in range(100):
        if i < 50:
            C.append(["
        else:
            C.append(["."] * 100)

    whitecnt = 1
    blackcnt = 1

    for i in range(1, 50, 2):
        if whitecnt == A:
            break
        for j in range(1, 100, 2):
            C[i][j] = '.'
            whitecnt += 1
            if whitecnt == A:
                break
    for i in range(51, 100, 2):
        if blackcnt == B:
            break
        for j in range(1, 100, 2):
            C[i][j] = '
            blackcnt += 1
            if blackcnt == B:
                break

    print(100, 100)
    for c in C:
        print("".join(c))




if __name__ == '__main__':
    main()

Solution (Python):
a,b=map(int,input().split())
ans1=['.']*2500
ans2=['
for i in range(b-1):
  ans1[2*i]='
for i in range(a-1):
  ans2[2*i]='.'
print(100,100)
for i in range(25):
  print(''.join(ans1[100*i:100*i+100]))
  print('.'*100)
for i in range(25):
  print('
  print(''.join(ans2[100*i:100*i+100]))

Solution (Python):
A, B = map(int, input().split())
print(100, 100)
G = [['.'] * 100 for _ in range(50)] + [['
for i in range(B - 1):
    G[(i // 50) * 2][(i % 50) * 2] = '
for i in range(A - 1):
    G[~((i // 50) * 2)][~((i % 50) * 2)] = '.'
for i in range(100):
    print(''.join(G[i]))

Solution (Python):
a,b=map(int,input().split())
ans=[[] for _ in range(100)]
for i in range(100):
    for j in range(100):
        if i<=49:
            ans[i].append(".")
        else:
            ans[i].append("
a-=1
b-=1
for i in range(0,50,2):
    for j in range(0,100,2):
        if b>0:
            ans[i][j]="
            b-=1
for i in range(51,100,2):
    for j in range(0,100,2):
        if a>0:
            ans[i][j]="."
            a-=1
print(100,100)
for i in range(100):
    print("".join(ans[i]))

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))


A, B = lr()
X = [['
A -= 1; B -= 1
h = 0; w = 0
while A:
    X[h][w] = '.'
    w += 2
    A -= 1
    if w >= 100:
        h += 2
        w = 0

h = 51; w = 0
while B:
    X[h][w] = '
    w += 2
    B -= 1
    if w >= 100:
        h += 2
        w = 0

X = [''.join(y) for y in X]
print(100, 100)
print('\n'.join(X))

Solution (Python):
def resolve():
    A, B = list(map(int, input().split()))
    K = 50
    grid = [["." for _ in range(2*K)] for __ in range(K)]
    grid += [["
    acnt = 1
    bcnt = 1
    for i in range(0, K-1):
        if bcnt >= B:
            break
        for j in range(2*K):
            for di, dj in [[-1, 0], [1, 0], [0, 1], [0, -1], [-1, -1], [-1, 1], [1, -1], [1, 1]]:
                if 0 <= i+di <= 2*K-1 and 0 <= j+dj <= 2*K-1:
                    if grid[i+di][j+dj] == "
                        break
            else:
                grid[i][j] = "
                bcnt += 1
                if bcnt >= B:
                    break
    
    for i in range(K+1, 2*K):
        if acnt >= A:
            break
        for j in range(2*K):
            for di, dj in [[-1, 0], [1, 0], [0, 1], [0, -1], [-1, -1], [-1, 1], [1, -1], [1, 1]]:
                if 0 <= i+di <= 2*K-1 and 0 <= j+dj <= 2*K-1:
                    if grid[i+di][j+dj] == ".":
                        break
            else:
                grid[i][j] = "."
                acnt += 1
                if acnt >= A:
                    break
    print(2*K, 2*K)
    [print("".join(grid[i])) for i in range(2*K)]
    
if '__main__' == __name__:
    resolve()

Solution (Python):
a, b = map(int, input().split())
y, x = 1, 1 
moves = ((1, 0), (0, 1), (0, -1), (-1, 0), (-1, -1), (1, -1), (-1, 1), (1, 1))

if a <= b:
    c1, c2 = '.', '
    res = [['.']*100 for _ in range(100)]
else:
    c1, c2 = '
    a, b = b, a
    res = [['

while a > 1 and b > 1:
    res[y][x] = c1
    for dy, dx in moves:
        res[y+dy][x+dx] = c2

    x += 4
    if x > 98:
        y += 4
        x = 1

    a -= 1
    b -= 1

    
for i in range(b):
    res[y][x] = c2
    x += 2
    if x > 98:
        y += 4
        x = 1

print(100, 100)
for h in range(100):
    print(''.join(res[h]))

Solution (Python):
a, b = map(int, input().split())
n = 24
unit = [
    '
    '
    '
    '....'
]
row = [
    '.' + unit[0]*n + '
    '.' + unit[1]*n + '
    '.' + unit[2]*n + '
    '.' + unit[3]*n + '
]
grid = []
for i in range(n):
    grid.append(list(row[0]))
    grid.append(list(row[1]))
    grid.append(list(row[2]))
    grid.append(list(row[3]))
"""

for i in range(n):
    grid[0][4*(i+1)] = 'x'
for i in range(n):
    grid[4*i][4] = 'y'

for i in range(n):
    grid[2][4*(i+1)-2] = 'w'
for i in range(n):
    grid[4*(i+1)-2][2] = 'v'
"""

for i in range(a//n+1):
    for j in range(n):
        if i * n + j < a-1:
            
            grid[4*(i+1)-2][4*(j+1)-2] = '


for i in range(b//n+1):
    for j in range(n):
        if i * n + j < b-1:
            
            grid[4*i][4*(j+1)] = '.'

print(len(grid), len(grid[0]))
for i in grid:
    print(''.join(i))

Solution (Python):
A,B=map(int,input().split())
G=[['.']*100 for i in range(100)]

for i in range(50):
    for j in range(100):
        G[i][j]='




white,black=1,1

for i in range(0,50,2):
    for j in range(0,100,2):
        if white==A:
            break
        G[i][j]='.'
        white+=1

for i in range(51,100,2):
    for j in range(0,100,2):
        if black==B:
            break
        G[i][j]='
        black+=1

print(100,100)
for i in range(100):
    print(*G[i],sep='')

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b = map(int, readline().split())
    grid = []
    for _ in range(50):
        grid.append(["

    for _ in range(50):
        grid.append(["."] * 100)

    w_row, w_col = 0, 0
    b_row, b_col = 51, 0

    for white in range(a - 1):
        grid[w_row][w_col] = "."
        w_row += 2
        if w_row == 50:
            w_row = 0
            w_col += 2

    for black in range(b - 1):
        grid[b_row][b_col] = "
        b_row += 2
        if b_row == 101:
            b_row = 51
            b_col += 2

    print(100, 100)
    for row_state in grid:
        print("".join(row_state))


if __name__ == '__main__':
    main()

Solution (Python):
a,b = map(int,input().split())
c1,c2,mx1,mx2 = (".","
grid = [[c1]*100 for _ in range(100)]
cnt1 = 1
cnt2 = 0   

for i in range(0,100,4):
    for j in range(0,100,4):
        if cnt1 < mx1:
            for k in range(i,i+3):
                for l in range(j,j+3):
                    if k == i+1 and l == j+1: continue
                    grid[k][l] = c2
            cnt1 += 1
            cnt2 += 1
        elif cnt2 < mx2:
            grid[i][j] = c2
            cnt2 += 1
        else:
            break

print(100,100)
for i in range(100): print("".join(grid[i]))

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    a,b=map(int,readline().split())
    
    h=100
    w=100
    ans=[["."]*100 if 0<=i<50 else ["
    cnt_b=1
    cnt_w=1
    for i in range(h):
        for j in range(w):
            if i%2==0 and j%2==0 and  ans[i][j]==".":
                if cnt_b<b:
                    ans[i][j]="
                    cnt_b+=1
            elif i%2==1 and j%2==0 and ans[i][j]=="
                if cnt_w<a:
                    ans[i][j]="."
                    cnt_w+=1

    print(h,w)
    for i in range(h):
        print("".join(ans[i]))

if __name__=="__main__":
    main()

Solution (Python):
A, B = map(int, input().split())

K = 50
G = [['

A -= 1
for i in range(0, 2 * K, 2):
    for j in range(0, 2 * K, 2):
        if A > 0:
            G[i][j] = '.'
            A -= 1
        else:
            break

B -= 1
for i in range(2 * K - 1, -1, -2):
    for j in range(2 * K - 1, -1, -2):
        if B > 0:
            G[i][j] = '
            B -= 1
        else:
            break

print (2 * K, 2 * K)
for g in G:
    print (*g, sep = '')

Solution (Python):
a, b = map(int, input().split())
M = [['

for i in range(a-1):
    M[(2*i//100)*2][2*i%100] = '.'

for i in range(b-1):
    M[99 - (2*i//100)*2][2*i%100] = '

print(100, 100) 
for l in M:
    print(''.join(l))

Solution (Python):
a,b = map(int,input().split())

d = [["."]*100 for i in range(100)]

i = 0
j = 0
while b > 1:

    count = 0
    while count < 50 and b > 1:
        d[i][j] = "
        count += 1
        b -= 1
        j += 2
    i += 2
    j = 0

for i in range(50,100):
    for j in range(100):
        d[i][j] = "

i = 0
j = 0
while a > 1:

    count = 0
    while count < 50 and a > 1:
        d[-i-1][-1-j] = "."
        count += 1
        a -= 1
        j += 2
    i += 2
    j = 0
print(100,100)
for i in d:
    print(*i,sep="")

Solution (Python):
a,b = map(int,input().split())

li = []
for _ in range(50):
    li.append(['.'] * 100)
for _ in range(50):
    li.append(['

for i in range(b-1):
    j = i // 50
    k = i % 50
    li[j*2][k*2] = '

for i in range(a-1):
    j = i // 50
    k = i % 50
    li[j*2 + 51][k*2] = '.'

print(100, 100)
for i in range(100):
    for j in range(100):
        print(li[i][j], end = '')
    print()

Solution (Python):
a,b = map(int,input().split())

w_o = [['.' for i in range(3)] for j in range(3)]
b_o = [['

        
w_c = [['
b_c = [['.' for i in range(3)] for j in range(3)]

w_c[1][1] = '.'
b_c[1][1] = '

ab = [['.' for i in range(99)] for j in range(99)]

a -= 1
b -= 1

a_y = a//33
a_x = a % 33

for i in range(17):
    for j in range(33):
        if a_y > i:
            
            for k in range(3):
                for l in range(3):
                    ab[i*3+k][j*3+l] = w_c[k][l]
        elif a_y == i:
            if a_x > j:
                for k in range(3):
                    for l in range(3):
                        ab[i*3+k][j*3+l] = w_c[k][l]
            else:
                for k in range(3):
                    for l in range(3):
                        ab[i*3+k][j*3+l] = w_o[k][l]
        else:
            for k in range(3):
                for l in range(3):
                    ab[i*3+k][j*3+l] = w_o[k][l]

if a > 0:
    b -= 1

if b == -1:
    print(51,99)
    for i in range(51):
        print(*ab[i],sep="")
    exit()

b_y = b//33
b_x = b % 33

for i in range(17,17+16,1):
    for j in range(33):
        if b_y > i-17:
            
            for k in range(3):
                for l in range(3):
                    ab[i*3+k][j*3+l] = b_c[k][l]
        elif b_y == i-17:
            if b_x > j:
                for k in range(3):
                    for l in range(3):
                        ab[i*3+k][j*3+l] = b_c[k][l]
            else:
                for k in range(3):
                    for l in range(3):
                        ab[i*3+k][j*3+l] = b_o[k][l]
        else:
            for k in range(3):
                for l in range(3):
                    ab[i*3+k][j*3+l] = b_o[k][l]                    

print(99,99)
                    
for i in range(99):
    print(*ab[i],sep="")

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())


    def increase_symbol(seq, sym, num):
        for i in range(1, 48, 2):
            for j in range(1, 98, 2):
                if num > 0:
                    seq[i][j] = sym
                    num -= 1
                else:
                    return


    
    a, b = mi()
    upper = [['
    lower = [['.'] * 99 for _ in range(49)]
    
    increase_symbol(upper, '.', a - 1)
    increase_symbol(lower, '

    grid = upper + lower
    print("98 99")
    for line in grid:
        print(''.join(line))

    


if __name__ == "__main__":
    main()

Solution (Python):
a,b=map(int,input().split())
grid=[['.']*100 for _ in range(100)]

for i in range(50):
    for j in range(100):
        grid[i][j]='

nx=0
ny=0
for _ in range(a-1):
    grid[ny][nx]='.'
    if nx<98:
        nx+=2
    else:
        nx=0
        ny+=2

nx=0
ny=51
for _ in range(b-1):
    grid[ny][nx]='
    if nx<98:
        nx+=2
    else:
        nx=0
        ny+=2

print(100,100)
for i in range(100):
    print(*grid[i],sep='')

Solution (Python):
a,b=map(int,input().split())
h,w=100,100
c=[["."]*w if int(i)<50 else ["

a-=1
b-=1
plus=True
h1,w1=0,0
while b:
  c[h1][w1]="
  b-=1
  if w1!=48:
    w1+=2
  else:
    if h1==48:break
    w1=0
    h1+=2
h2,w2=51,0
while a:
  c[h2][w2]="."
  a-=1
  if w2!=48:
    w2+=2
  else:
    if h2==99:break
    w2=0
    h2+=2
print(h,w)
for ci in c:
  ans=""
  for cc in ci:
    ans+=cc
  print(ans)

Solution (Python):
def main():
    A, B = list(map(int, input().split(' ')))
    A -= 1
    B -= 1
    K = 50
    H, W = 2 * K, 2 * K
    ans = list()
    for h in range(K):
        if h % 2 == 0:
            ans.append('
        else:
            white_cells = K if A >= K else max([A, 0])
            ans.append('
            A -= white_cells
    for h in range(K):
        if h % 2 == 0:
            ans.append('.' * W)
        else:
            black_cells = K if B >= K else max([B, 0])
            ans.append('.
            B -= black_cells
    print('{} {}'.format(H, W))
    for s in ans:
        print(s)


if __name__ == '__main__':
    main()

Solution (Python):
a,b=map(int,input().split())
G=[[0]*25 for i in range(25)]
x=min(a,b) 
y=max(a,b) 
C=[x-1,y-x+1]
for i in range(25):
    for j in range(25):
        if C[0]>0:
            G[i][j]=1
            C[0]-=1
        elif C[1]>0:
            G[i][j]=2
            C[1]-=1
        else:
            break
    if C[0]==C[1]==0:
        break

P=[]
if a<b:
    P.append(["....","....","....","...."])
    P.append(["
    P.append(["....",".
else:
    P.append(["
    P.append(["...
    P.append(["

print(100,100)
for i in range(25):
    for k in range(4):
        s=""
        for j in range(25):
            s+=P[G[i][j]][k]
        print(s)

Solution (Python):
a, b = map(int, input().split())
a -= 1
b -= 1
print(82, 51)
for i in range(41):
  for j in range(51):
    if i % 2 == 0 or j % 2 == 0 or b == 0:
      print('.', end='')
    else:
      print('
      b -= 1
  print('')
for i in range(41):
  for j in range(51):
    if i % 2 == 0 or j % 2 == 0 or a == 0:
      print('
    else:
      print('.', end='')
      a -= 1
  print('')

Solution (Python):
a, b = map(int, input().split())

grid = [["."]*100 for _ in range(50)] + [["

for i in range(0, 50, 2):
  flag = False
  for j in range(0, 50, 2):
    if b > 1:
      b -= 1
      grid[i][j] = "
    if b == 1:
      flag = True
      break
  if flag:
    break

for i in range(99, 50, -2):
  flag = False
  for j in range(99, 50, -2):
    if a > 1:
      a -= 1
      grid[i][j] = "."
    if a == 1:
      flag = True
      break
  if flag:
    break
    

print(100, 100)
for i in range(100):
  print("".join(grid[i]))

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A,B=map(int,input().split())
    ans=[['
    A-=1
    B-=1
    y,x=1,1
    for _ in range(A):
        ans[y][x]='.'
        x+=2
        if x>=100:
            if x%2:
                y+=1
                x=2
            else:
                y+=2
                x=1
    y,x=51,1
    for _ in range(B):
        ans[y][x]='
        x+=2
        if x>=100:
            if x%2:
                y+=1
                x=2
            else:
                y+=2
                x=1
    print(100,100)
    for row in ans:
        print(''.join(row))
    

if __name__ == '__main__':
    main()

Solution (Python):

import sys
input = sys.stdin.readline









A,B = map(int,input().split())


X = []
for i in range(100):
    if i<50:
        X.append(["."]*100)
    else:
        X.append(["


A = A-1 

q,r = A//50, A%50
for i in range(q):
    for j in range(50):
        X[99-i*2][j*2] = "."
for i in range(r):
    X[51][i*2] = "."


B = B-1 

q,r = B//50, B%50
for i in range(q):
    for j in range(50):
        X[i*2][j*2] = "
for i in range(r):
    X[48][i*2] = "

print(100,100)
for x in X:
    print("".join(x))

Solution (Python):

"""
問題：
100*100以下のグリッドを作成し、
白・黒に色を塗る時、白の連結成分の個数をwに、
黒の連結成分をbとしたものを出力せよ
解法：
まずグリッドは100*100としてよい。
上50行を黒、下50行を白で塗る(w,b>=1)
上50行100列のうち、w-1個だけ斜めに配置する
同じように下50行100列もb-1個だけ斜めに配置
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
w,b = map(int,readline().split())
H,W = 100,100
print(H,W)
ans = [["."]*W for _ in range(H//2)]
ans += [["

i,j = 0,0
res = b-1
while True:
    if res == 0:
        break
    if j+2 >= W:
        i += 2
        j = 0 if even(i) else 1
        ans[i][j] = "
        res -= 1
    else:
        j += 2
        ans[i][j] = "
        res -= 1
i,j = 51,0
res = w-1      
while True:
    if res == 0:
        break
    if j+2 >= W:
        i += 2
        j = 0 if even(i) else 1
        ans[i][j] = "."
        res -= 1
    else:
        j += 2
        ans[i][j] = "."
        res -= 1
for i in ans:
    print("".join(i))

Solution (Python):
A, B = map(int,input().split())
ans = [['
for x in range(A-1):
    i = x // 25
    j = 2 * (i % 2) + 4 * (x % 25)
    ans[i][j] = '.'
for x in range(B-1):
    i = 99 - x // 25
    j = 2 * (i % 2) + 4 * (x % 25)
    ans[i][j] = '
print(*[100, 100])
for i in range(100):
    print(''.join(ans[i]))

Solution (Python):
A, B = map(int, open(0).read().split())

grid = [["

for i in range(A - 1):
    grid[i // 50 * 2][i % 50 * 2] = "."

for i in range(B - 1):
    grid[i // 50 * 2 + 51][i % 50 * 2] = "

print(100, 100)
for v in grid:
    print("".join(v))

Solution (Python):
A,B=map(int,input().split())

g=[["


for i in range(A-1):
    x=(i%50)*2
    y=(i//50)*2
    g[y][x]="."

for i in range(B-1):
    x=(i%50)*2
    y=51+(i//50)*2
    g[y][x]="

print(100,100)
for n in g:
    print("".join(n))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b = map(int, read().split())
h, w = 100, 100
print(h, w)
ans = [['
if a > 1:
    cnt = 0
    flag = False
    for i in range(0, h, 2):
        for j in range(0, w, 2):
            ans[i][j] = '.'
            cnt += 1
            if a - 1 == cnt:
                flag = True
                break
        if flag:
            break
if b > 1:
    cnt = 0
    flag = False
    for i in range(h // 2 + 1, h, 2):
        for j in range(0, w, 2):
            ans[i][j] = '
            cnt += 1
            if b - 1 == cnt:
                flag = True
                break
        if flag:
            break
for aa in ans:
    print(''.join(aa))

Solution (Python):
nim, mike = map(int, input().split())

g = [["

for i in range(nim-1):
    x, y = (i%50)*2, (i//50)*2
    g[y][x] = "."
for i in range(mike-1):
    x, y = (i%50)*2, 51+(i//50)*2
    g[y][x] = "

print(100, 100)
for g_i in g:
    print("".join(g_i))

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    a,b = map(int, input().split())

    f = 0
    if a > b:
        a,b = b,a
        f = 1
    if a == 1:
        b += 1

    d = [[-1]*100 for _ in range(100)]
    for i in range(100):
        for j in range(100):
            if a == 1:
                d[i][j] = 1
                if i >= 1:
                    if d[i-1][j] == 1:
                        b += 1
                continue
            if (i+j)%2 == 0:
                d[i][j] = 0
                a -= 1
            else:
                d[i][j] = 1
                b -= 1
        if a == 1:
            k = i
            break

    if k%2 == 0:
        b -= 2
    else:
        b -= 1
    for i in range(100):
        d[k+1][i] = 1
        if d[k][i] == 0:
            b += 1
    for i in range(100):
        d[k+2][i] = 0

    if b == -1:
        b = 0
    for i in range(k+3, 100, 2):
        for j in range(100):
            if b == 0:
                break
            if (i+j)%2 == 0:
                d[i][j] = 0
            else:
                d[i][j] = 1
                b -= 1
        else:
            continue
        break

    print(100, 100)
    if f:
        for i in range(100):
            res = []
            for j in range(100):
                if d[i][j] == 1:
                    res.append('.')
                else:
                    res.append('
            print(*res, sep='')
    else:
        for i in range(100):
            res = []
            for j in range(100):
                if d[i][j] == 1:
                    res.append('
                else:
                    res.append('.')
            print(*res, sep='')

if __name__ == '__main__':
    main()

Solution (Python):
A,B=map(int,input().split())

G=list()
for i in range(50):
  G.append(['
for i in range(50):
  G.append(['.']*100)

for i in range(A-1):
  G[2*(i//50)][2*(i%50)]='.'
for i in range(B-1):
  G[50+2*(i//50)+1][2*(i%50)]='

print(100,100)
for i in range(100):
  print(''.join(G[i]))

Solution (Python):
a,b = map(int, input().split())

N=100
ans = [["

for i in range(N):
    for j in range(N//2,N):
        ans[j][i]="."

for i in range(0,N,2):
    if a==1:
        break
    for j in range(0,N,2):
        ans[i][j]="."
        a-=1
        if a==1:
            break

for i in range(1+N//2,N,2):
    if b==1:
        break
    for j in range(0,N,2):
        ans[i][j]="
        b-=1
        if b==1:
            break

print(100,100)
for i in range(N):
    print(*ans[i],sep="")

Solution (Python):

def main():
    A, B = map(int, input().split())
    t = [[0] * 100 for _ in range(50)] + [[1] * 100 for _ in range(50)]
    x = 0
    b = False
    for i in range(0, 50, 2):
        for j in range(0, 100, 2):
            if x == A - 1:
                b = True
                break
            t[i][j] = 1
            x += 1
        if b:
            break
    x = 0
    b = False
    for i in range(51, 100, 2):
        for j in range(0, 100, 2):
            if x == B - 1:
                b = True
                break
            t[i][j] = 0
            x += 1
        if b:
            break
    print(100,100)
    for i in range(100):
        print(''.join('.' if i == 1 else '
main()

Solution (Python):
def main():
    A, B = map(int, input().split())
    s, t, a, b = '.', '
    if A > B:
        s, t, a, b = t, s, b, a
    S = 100
    T = [[s] * S for _ in range(S)]
    
    a -= 1
    for i in range(b):
        X, Y = (i * 4)// len(T) * 4, ((i * 4)% len(T))
        T[X][Y:Y+3] = [t] * 3
        T[X+1][Y:Y+3] = [t] * 3
        T[X+2][Y:Y+3] = [t] * 3
        if a > 0:
            T[X+1][Y+1] = s
            a -= 1
    print(len(T), len(T[0]))
    for t in T:
        print(''.join(t))
main()

Solution (Python):

import sys
try:
    from typing import List
except ImportError:
    pass


def solve(A: int, B: int):
    A -= 1
    B -= 1
    print(-(-A // 50 + -B // 50) * 2 + 2, 100)
    while A:
        print("
        n = min(A, 50)
        print(".
        A -= n
    print("
    print("." * 100)
    while B:
        n = min(B, 50)
        print(".
        B -= n
        print("." * 100)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(A, B)


if __name__ == '__main__':
    main()

Solution (Python):
A,B=map(int,input().split())

mat=[]
for i in range(100):
  array=["."]*50+["
  mat.append(array)

for i in range(B-1):
  j=2*(i//25)
  k=2*(i%25)
  mat[j][k]="
for i in range(A-1):
  j=2*(i//25)
  k=2*(i%25)+51
  mat[j][k]="."
  
print(100,100)
for i in range(100):
  print("".join(mat[i]))

Solution (Python):
A,B=map(int,input().split())

mat=[]
for i in range(100):
  array=[True]*50+[False]*50
  mat.append(array)

for i in range(B-1):
  j=2*(i//25)
  k=2*(i%25)
  mat[j][k]=False
for i in range(A-1):
  j=2*(i//25)
  k=2*(i%25)+51
  mat[j][k]=True
  
print(100,100)
for i in range(100):
  array=["." if x else "
  print("".join(array))

Solution (Python):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

def main():
    a, b = MII()
    grid=[['
    grid+=[['.' for i in range(100)] for j in range(50)]
    for i in range(a-1):
        grid[(i//50)*2][(i%50)*2]='.'
    for i in range(b-1):
        grid[(i//50)*2+51][(i%50)*2]='
    print(100,100)
    print(*[''.join(grid[i]) for i in range(100)], sep='\n')

if __name__ == '__main__':
    main()

Solution (Python):
from copy import deepcopy
a,b = map(int, input().split())
grid = [["." for i in range(100)] for j in range(50)]+[["
print(100,100)
for i in range(b-1):
  x = i//50
  y = i%50
  grid[x*2][y*2] = "
for i in range(a-1):
  x = i//50
  y = i%50
  grid[51+x*2][y*2] = "."
for arr in grid:
  print(*arr,sep="")