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

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

h = A("h")
e = B("e")
i = A("i")
l = B("l")
b = B("b")
n = A("n")
d = A("d")
j = A("j")
g = A("g")

h.t = g
e.z = b
i.t = d
l.z = b
b.z = l
n.t = d
d.t = i
j.t = d
g.t = i
assert j.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

h = A("h")
e = B("e")
i = A("i")
l = B("l")
b = B("b")
n = A("n")
d = A("d")
j = A("j")
g = A("g")

h.t = g
e.z = b
i.t = d
l.z = b
b.z = l
n.t = d
d.t = i
j.t = d
g.t = i
assert j.t.t.t.t.txt == "i"