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

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

b = A("b")
k = B("k")
j = A("j")
g = A("g")
i = B("i")
l = B("l")
h = B("h")

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

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

b = A("b")
k = B("k")
j = A("j")
g = A("g")
i = B("i")
l = B("l")
h = B("h")

b.y = i
k.x = h
j.y = i
g.y = k
i.x = k
l.x = i
h.x = i
assert i.x.x.x.txt == "i"