Buggy python submission (verdict: Runtime Error):
def insertionSort(A,n,g):
    for i in range(g,n,1):
        v = int(A[i])
        j = i - g
        while j >= 0 and int(A[j]) > v:
            global cnt
            A[j + g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = str(v)
            
def shellSort(A,n):
    global cnt
    global G
    G = []
    cnt = 0
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
    m = len(G)
    print(m)
    G.reverse()
    print(' '.join(map(str, G)))
    for i in range(0,m,1):
        insertionSort(A,n,G[i])
    print(cnt)
        

n = int(input())
#改行で標準入力を受け付ける場合
A = []
for i in range(n):
    A.append(input())
shellSort(A,n)
print('\n'.join(A))


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,n,g):
    for i in range(g,n,1):
        v = int(A[i])
        j = i - g
        while j >= 0 and int(A[j]) > v:
            global cnt
            A[j + g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = str(v)
            
def shellSort(A,n):
    global cnt
    global G
    G = []
    cnt = 0
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
    m = len(G)
    print(m)
    G.reverse()
    print(' '.join(map(str, G)))
    for i in range(0,m,1):
        insertionSort(A,n,G[i])
    print(cnt)
        

n = int(input())
#改行で標準入力を受け付ける場合
A = []
for i in range(n):
    A.append(input())
shellSort(A,n)
print('\n'.join(A))


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,n,g):
    for i in range(g,n,1):
        v = int(A[i])
        j = i - g
        while j >= 0 and int(A[j]) > v:
            global cnt
            A[j + g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = str(v)
            
def shellSort(A,n):
    global cnt
    global G
    G = []
    cnt = 0
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        if(len(G)>100):
            break
    m = len(G)
    print(m)
    G.reverse()
    print(' '.join(map(str, G)))
    for i in range(0,m,1):
        insertionSort(A,n,G[i])
    print(cnt)
        

n = int(input())
#改行で標準入力を受け付ける場合
A = []
for i in range(n):
    A.append(input())
shellSort(A,n)
print('\n'.join(A))


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,n,g):
    for i in range(g,n,1):
        v = int(A[i])
        j = i - g
        while j >= 0 and int(A[j]) > v:
            global cnt
            A[j + g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = str(v)
            
def shellSort(A,n):
    global cnt
    global G
    G = []
    cnt = 0
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        if(len(G)>100):
            break
    m = len(G)
    print(m)
    G.reverse()
    print(' '.join(map(str, G)))
    for i in range(0,m,1):
        insertionSort(A,n,G[i])
    print(cnt)
        

n = int(input())
#改行で標準入力を受け付ける場合
A = []
for i in range(n):
    A.append(input())
shellSort(A,n)
print('\n'.join(A))


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,n,g):
    for i in range(g,n,1):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            global cnt
            A[j + g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = v
            
def shellSort(A,n):
    global cnt
    global G
    G = []
    cnt = 0
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        if(len(G)>100):
            break
    m = len(G)
    print(m)
    G.reverse()
    print(' '.join(map(str, G)))
    for i in range(0,m,1):
        insertionSort(A,n,G[i])
    print(cnt)
        

n = int(input())
#改行で標準入力を受け付ける場合
A = [int(input()) for i in range(n)]
shellSort(A,n)
# print('\n'.join(A))
print(*A,sep='\n')


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,n,g):
    for i in range(g,n,1):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            global cnt
            A[j + g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = v
            
def shellSort(A,n):
    global cnt
    global G
    G = []
    cnt = 0
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        if(len(G)>100):
            break
    m = len(G)
    print(m)
    G.reverse()
    print(' '.join(map(str, G)))
    for i in range(0,m,1):
        insertionSort(A,n,G[i])
    print(cnt)
        

n = int(input())
#改行で標準入力を受け付ける場合
A = [int(input()) for i in range(n)]
shellSort(A,n)
# print('\n'.join(A))
print(*A,sep='\n')


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
 
n = int(input())
A = [int(input()) for i in range(n)]
 
cnt = 0
G = [1]
for i in range(99):
    if n < 1 + 3*G[-1]:
        break
    G.append(1 + 3*G[-1])
m = len(G)
G.reverse()
for i in range(m):
    insertionSort(A, n, G[i])
 
print(m)
print(*G)
print(cnt)
print(*A, sep='\n')


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
 
def insertionsort(a, n, g):
    global c
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            c += 1
        a[j + g] = v
 
c = 0
g = [1]
while g[-1] * 3 + 1 < n:
    g.append(g[-1] * 3 + 1)
g.reverse()
for i in range(len(g)):
    insertionsort(a, n, g[i])
print(len(g))
print(" ".join(map(str, g)))
print(c)
for i in range(n):
    print(a[i])


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,n,g):
    for i in range(g,n,1):
        v = int(A[i])
        j = i - g
        while j >= 0 and int(A[j]) > v:
            global cnt
            A[j + g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = str(v)
             
def shellSort(A,n):
    global cnt
    G = []
    cnt = 0
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
         
    m = len(G)
    print(m)
    G.reverse()
    print(' '.join(map(str, G)))
    for i in range(0,m,1):
        insertionSort(A,n,G[i])
    print(cnt)
         
 
n = int(input())
#改行で標準入力を受け付ける場合
A = []
for i in range(n):
    A.append(input())
shellSort(A,n)
print('\n'.join(A))


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
ef insert_sort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return cnt
 
def shellSort(A, n):
    cnt = 0
    G = []; h = 0
    while h <= n:
        if 3 * h + 1 <= n:
            h = 3 * h + 1
            G.append(h)
        else: break
    G = sorted(G, reverse=True)
    m = len(G)
    for i in range(m):
        cnt = insert_sort(A, n, G[i], cnt)
    return m, cnt, G
 
A = []
n = int(input())
for i in range(n):
    A.append(int(input()))
 
m, cnt, G = shellSort(A, n)
print(m)
for i in range(m):
    if i == m - 1:
        print(G[i])
    else:
        print(G[i], end=" ")
print(cnt)
for i in A:
    print(i)


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,n,g):
    for i in range(g,n,1):
        v = int(A[i])
        j = i - g
        while j >= 0 and int(A[j]) > v:
            global cnt
            A[j + g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = str(v)
            
def shellSort(A,n):
    global cnt
    global G
    G = []
    cnt = 0
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        
    m = len(G)
    print(m)
    G.reverse()
    print(' '.join(map(str, G)))
    for i in range(0,m,1):
        insertionSort(A,n,G[i])
    print(cnt)
        

n = int(input())
#改行で標準入力を受け付ける場合
A = [0] * n
for i in range(n):
    A[i] = input()
shellSort(A,n)
print('\n'.join(A))


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,n,g):
    for i in range(g,n,1):
        v = int(A[i])
        j = i - g
        while j >= 0 and int(A[j]) > v:
            global cnt
            A[j + g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = str(v)
            
def shellSort(A,n):
    global cnt
    global G
    G = []
    cnt = 0
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        
    m = len(G)
    print(m)
    G.reverse()
    print(' '.join(map(str, G)))
    for i in range(0,m,1):
        insertionSort(A,n,G[i])
    print(cnt)
        

n = int(input())
#改行で標準入力を受け付ける場合
A = [0] * n
for i in range(n):
    A[i] = input()
shellSort(A,n)
print('\n'.join(A))


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])

Buggy python submission (verdict: Runtime Error):
def insertionSort(A,n,g):
    for i in range(g,n,1):
        v = int(A[i])
        j = i - g
        while j >= 0 and int(A[j]) > v:
            global cnt
            A[j + g] = A[j]
            j = j - g
            cnt = cnt + 1
        A[j+g] = str(v)
            
def shellSort(A,n):
    global cnt
    global G
    G = []
    cnt = 0
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        
    m = len(G)
    print(m)
    G.reverse()
    print(' '.join(map(str, G)))
    for i in range(0,m,1):
        insertionSort(A,n,G[i])
    print(cnt)
        

n = int(input())
#改行で標準入力を受け付ける場合
A = [0] * n
for i in range(n):
    A[i] = input()
shellSort(A,n)
print('\n'.join(A))


Fixed submission:
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])