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

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

d = A("d")
h = B("h")
f = B("f")
l = A("l")
k = A("k")
c = B("c")
a = B("a")
j = A("j")
i = B("i")
e = A("e")

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

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

d = A("d")
h = B("h")
f = B("f")
l = A("l")
k = A("k")
c = B("c")
a = B("a")
j = A("j")
i = B("i")
e = A("e")

d.t = f
h.x = a
f.x = a
l.t = a
k.t = f
c.x = a
a.x = f
j.t = a
i.x = a
e.t = a
assert h.x.x.x.x.x.x.txt == "f"