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

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

b = A("b")
e = B("e")
g = A("g")
c = B("c")
i = B("i")
d = B("d")
j = A("j")
k = B("k")
a = B("a")

b.y = e
e.o = b
g.y = i
c.o = b
i.o = j
d.o = g
j.y = k
k.o = j
a.o = b
assert a.o.y.o.y.o.y.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

b = A("b")
e = B("e")
g = A("g")
c = B("c")
i = B("i")
d = B("d")
j = A("j")
k = B("k")
a = B("a")

b.y = e
e.o = b
g.y = i
c.o = b
i.o = j
d.o = g
j.y = k
k.o = j
a.o = b
assert a.o.y.o.y.o.y.o.y.txt == "e"