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

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

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

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

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

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

f.o = d
k.x = e
b.o = d
g.x = j
d.x = e
c.x = e
e.o = g
j.o = k
l.x = j
i.x = f
assert g.x.o.x.o.x.o.x.o.x.o.txt == "k"