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

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

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

n.x = b
g.s = b
g.z = b
h.s = g
h.z = g
b.s = g
b.z = h
assert n.x.z.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

n.x = b
g.s = b
g.z = b
h.s = g
h.z = g
b.s = g
b.z = h
assert n.x.z.s.s.txt == "b"