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

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

i = A("i")
d = B("d")
m = B("m")
j = A("j")
l = A("l")
h = B("h")
b = A("b")
a = B("a")
g = B("g")
f = B("f")

i.x = m
i.t = m
d.o = g
m.o = h
j.x = d
j.t = f
l.x = f
l.t = d
h.o = d
b.x = d
b.t = h
a.o = m
g.o = h
f.o = m
assert h.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.t: B = None
        self.txt = txt

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

i = A("i")
d = B("d")
m = B("m")
j = A("j")
l = A("l")
h = B("h")
b = A("b")
a = B("a")
g = B("g")
f = B("f")

i.x = m
i.t = m
d.o = g
m.o = h
j.x = d
j.t = f
l.x = f
l.t = d
h.o = d
b.x = d
b.t = h
a.o = m
g.o = h
f.o = m
assert h.o.o.o.o.txt == "d"