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

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

j = A("j")
h = B("h")
e = A("e")
f = B("f")
n = B("n")
i = A("i")

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

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

j = A("j")
h = B("h")
e = A("e")
f = B("f")
n = B("n")
i = A("i")

j.u = e
h.q = f
h.t = n
e.u = j
f.q = h
f.t = h
n.q = h
n.t = h
i.u = e
assert j.u.u.u.u.u.txt == "e"