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

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: C = None
        self.w: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

n = A("n")
h = B("h")
b = C("b")
i = B("i")
d = C("d")

n.u = b
n.o = b
n.s = d
h.q = b
h.p = b
h.w = i
b.w = d
i.q = b
i.p = d
i.w = h
d.w = b
assert h.w.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.o: C = None
        self.s: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: C = None
        self.w: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

n = A("n")
h = B("h")
b = C("b")
i = B("i")
d = C("d")

n.u = b
n.o = b
n.s = d
h.q = b
h.p = b
h.w = i
b.w = d
i.q = b
i.p = d
i.w = h
d.w = b
assert h.w.q.w.w.txt == "b"