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

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

n = A("n")
j = B("j")
h = B("h")

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

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

n = A("n")
j = B("j")
h = B("h")

n.u = j
j.u = h
j.t = h
h.u = j
h.t = j
assert h.u.u.t.txt == "j"