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

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

g = A("g")
i = B("i")
d = B("d")
c = A("c")
f = A("f")
b = A("b")
e = A("e")
a = B("a")
n = B("n")
h = A("h")

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

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

g = A("g")
i = B("i")
d = B("d")
c = A("c")
f = A("f")
b = A("b")
e = A("e")
a = B("a")
n = B("n")
h = A("h")

g.t = d
i.o = f
d.o = f
c.t = a
f.t = i
b.t = d
e.t = i
a.o = b
n.o = e
h.t = a
assert a.o.t.o.t.txt == "i"