class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: C = None
        self.txt = txt

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

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

n = A("n")
b = B("b")
a = C("a")
f = A("f")
e = B("e")

n.z = a
n.p = a
b.u = e
b.q = e
a.o = e
f.z = a
f.p = a
e.u = b
e.q = b
assert e.q.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: C = None
        self.txt = txt

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

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

n = A("n")
b = B("b")
a = C("a")
f = A("f")
e = B("e")

n.z = a
n.p = a
b.u = e
b.q = e
a.o = e
f.z = a
f.p = a
e.u = b
e.q = b
assert e.q.q.u.txt == "b"