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

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

i = A("i")
b = B("b")
h = A("h")
j = B("j")
d = A("d")
c = B("c")

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

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

i = A("i")
b = B("b")
h = A("h")
j = B("j")
d = A("d")
c = B("c")

i.u = b
b.t = j
h.u = b
j.t = b
d.u = j
c.t = j
assert i.u.t.t.t.t.t.txt == "j"