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

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

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

a.o = e
c.t = e
g.t = b
b.o = e
e.o = b
i.t = e
assert a.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

a.o = e
c.t = e
g.t = b
b.o = e
e.o = b
i.t = e
assert a.o.o.o.o.txt == "b"