class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

i = A("i")
k = B("k")
h = B("h")
n = B("n")
g = B("g")
e = B("e")

i.y = h
k.x = i
h.x = i
n.x = i
g.x = i
e.x = i
assert n.x.y.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

i = A("i")
k = B("k")
h = B("h")
n = B("n")
g = B("g")
e = B("e")

i.y = h
k.x = i
h.x = i
n.x = i
g.x = i
e.x = i
assert n.x.y.x.y.txt == "h"