import sys

def checkValid(i, j, grid):
    # i-2, j+1
    y, x = i-2,  j+1
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    # i-2, j-1
    y, x = i-2, j-1
    if y >= 0 and x >= 0:
        if grid[y][x] == 'k':
            return False

    # i+2, j+1
    y, x = i+2, j+1
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    # i+2, j-1
    y, x = i+2, j-1
    if y < len(grid) and x >= 0:
        if grid[y][x] == 'k':
            return False

    # i+1, j+2
    y, x = i+1, j+2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    # i-1, j+2
    y, x = i-1, j+2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False

    # i+1, j-2
    y, x = i+1, j+2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    # i-1, j-2
    y, x = i-1, j+2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    return True

grid = []
total = 0
for line in sys.stdin:
    row = []
    for c in line:
        row.append(c)
        if c == 'k':
            total += 1
    grid.append(row)

if total != 9:
    print("invalid")
    exit(0)

for i in range(0, len(grid)):
    for j in range(0, len(grid[0])):
        # grid[i][j]
        if grid[i][j] == 'k':
            if not checkValid(i, j, grid):
                print("invalid")
                exit(0)
print("valid")

65dda499785f6e2bf0b1be6b4c0c4b17dabfd465
<mask token>


def checkValid(i, j, grid):
    y, x = i - 2, j + 1
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 2, j - 1
    if y >= 0 and x >= 0:
        if grid[y][x] == 'k':
            return False
    y, x = i + 2, j + 1
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i + 2, j - 1
    if y < len(grid) and x >= 0:
        if grid[y][x] == 'k':
            return False
    y, x = i + 1, j + 2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 1, j + 2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i + 1, j + 2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 1, j + 2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    return True


<mask token>

<mask token>


def checkValid(i, j, grid):
    y, x = i - 2, j + 1
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 2, j - 1
    if y >= 0 and x >= 0:
        if grid[y][x] == 'k':
            return False
    y, x = i + 2, j + 1
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i + 2, j - 1
    if y < len(grid) and x >= 0:
        if grid[y][x] == 'k':
            return False
    y, x = i + 1, j + 2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 1, j + 2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i + 1, j + 2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 1, j + 2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    return True


<mask token>
for line in sys.stdin:
    row = []
    for c in line:
        row.append(c)
        if c == 'k':
            total += 1
    grid.append(row)
if total != 9:
    print('invalid')
    exit(0)
for i in range(0, len(grid)):
    for j in range(0, len(grid[0])):
        if grid[i][j] == 'k':
            if not checkValid(i, j, grid):
                print('invalid')
                exit(0)
print('valid')

<mask token>


def checkValid(i, j, grid):
    y, x = i - 2, j + 1
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 2, j - 1
    if y >= 0 and x >= 0:
        if grid[y][x] == 'k':
            return False
    y, x = i + 2, j + 1
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i + 2, j - 1
    if y < len(grid) and x >= 0:
        if grid[y][x] == 'k':
            return False
    y, x = i + 1, j + 2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 1, j + 2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i + 1, j + 2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 1, j + 2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    return True


grid = []
total = 0
for line in sys.stdin:
    row = []
    for c in line:
        row.append(c)
        if c == 'k':
            total += 1
    grid.append(row)
if total != 9:
    print('invalid')
    exit(0)
for i in range(0, len(grid)):
    for j in range(0, len(grid[0])):
        if grid[i][j] == 'k':
            if not checkValid(i, j, grid):
                print('invalid')
                exit(0)
print('valid')

import sys


def checkValid(i, j, grid):
    y, x = i - 2, j + 1
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 2, j - 1
    if y >= 0 and x >= 0:
        if grid[y][x] == 'k':
            return False
    y, x = i + 2, j + 1
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i + 2, j - 1
    if y < len(grid) and x >= 0:
        if grid[y][x] == 'k':
            return False
    y, x = i + 1, j + 2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 1, j + 2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i + 1, j + 2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    y, x = i - 1, j + 2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    return True


grid = []
total = 0
for line in sys.stdin:
    row = []
    for c in line:
        row.append(c)
        if c == 'k':
            total += 1
    grid.append(row)
if total != 9:
    print('invalid')
    exit(0)
for i in range(0, len(grid)):
    for j in range(0, len(grid[0])):
        if grid[i][j] == 'k':
            if not checkValid(i, j, grid):
                print('invalid')
                exit(0)
print('valid')

import sys

def checkValid(i, j, grid):
    # i-2, j+1
    y, x = i-2,  j+1
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    # i-2, j-1
    y, x = i-2, j-1
    if y >= 0 and x >= 0:
        if grid[y][x] == 'k':
            return False

    # i+2, j+1
    y, x = i+2, j+1
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    # i+2, j-1
    y, x = i+2, j-1
    if y < len(grid) and x >= 0:
        if grid[y][x] == 'k':
            return False

    # i+1, j+2
    y, x = i+1, j+2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    # i-1, j+2
    y, x = i-1, j+2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False

    # i+1, j-2
    y, x = i+1, j+2
    if y < len(grid) and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    # i-1, j-2
    y, x = i-1, j+2
    if y >= 0 and x < len(grid[0]):
        if grid[y][x] == 'k':
            return False
    return True

grid = []
total = 0
for line in sys.stdin:
    row = []
    for c in line:
        row.append(c)
        if c == 'k':
            total += 1
    grid.append(row)

if total != 9:
    print("invalid")
    exit(0)

for i in range(0, len(grid)):
    for j in range(0, len(grid[0])):
        # grid[i][j]
        if grid[i][j] == 'k':
            if not checkValid(i, j, grid):
                print("invalid")
                exit(0)
print("valid")
