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

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

i = A("i")
n = B("n")
b = B("b")
j = A("j")
d = B("d")
f = A("f")
e = B("e")
a = A("a")
k = A("k")
l = B("l")

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

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

i = A("i")
n = B("n")
b = B("b")
j = A("j")
d = B("d")
f = A("f")
e = B("e")
a = A("a")
k = A("k")
l = B("l")

i.x = n
n.o = l
b.o = e
j.x = l
d.o = b
f.x = b
e.o = b
a.x = b
k.x = n
l.o = n
assert a.x.o.o.o.o.txt == "b"