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

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

n = A("n")
b = B("b")
m = B("m")
h = B("h")

n.u = b
n.q = b
b.z = h
m.z = b
h.z = b
assert b.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: B = None
        self.txt = txt

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

n = A("n")
b = B("b")
m = B("m")
h = B("h")

n.u = b
n.q = b
b.z = h
m.z = b
h.z = b
assert b.z.z.z.txt == "h"