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

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

d = A("d")
j = B("j")
e = B("e")
a = A("a")
c = A("c")
h = B("h")
m = B("m")
i = A("i")

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

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

d = A("d")
j = B("j")
e = B("e")
a = A("a")
c = A("c")
h = B("h")
m = B("m")
i = A("i")

d.t = e
j.u = a
e.u = a
a.t = j
c.t = e
h.u = c
m.u = a
i.t = j
assert c.t.u.t.u.t.u.txt == "a"