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

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

i = A("i")
h = B("h")
a = B("a")
e = B("e")
d = B("d")
k = A("k")
m = A("m")
c = B("c")

i.y = k
h.x = m
a.x = m
e.x = m
d.x = k
k.y = i
m.y = i
c.x = m
assert c.x.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

i = A("i")
h = B("h")
a = B("a")
e = B("e")
d = B("d")
k = A("k")
m = A("m")
c = B("c")

i.y = k
h.x = m
a.x = m
e.x = m
d.x = k
k.y = i
m.y = i
c.x = m
assert c.x.y.y.y.y.y.txt == "i"