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

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

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

n = A("n")
k = B("k")
f = C("f")
j = C("j")

n.w = f
n.o = f
n.q = f
k.r = j
k.t = f
f.u = j
f.x = j
f.q = k
j.u = f
j.x = f
j.q = k
assert f.q.t.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.o: C = None
        self.q: C = None
        self.txt = txt

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

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

n = A("n")
k = B("k")
f = C("f")
j = C("j")

n.w = f
n.o = f
n.q = f
k.r = j
k.t = f
f.u = j
f.x = j
f.q = k
j.u = f
j.x = f
j.q = k
assert f.q.t.u.x.txt == "f"