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

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

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

k = A("k")
j = B("j")
b = C("b")
e = C("e")
d = A("d")

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

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

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

k = A("k")
j = B("j")
b = C("b")
e = C("e")
d = A("d")

k.o = e
k.w = d
k.q = d
j.o = e
j.u = d
b.w = e
b.s = j
b.p = j
e.w = b
e.s = j
e.p = j
d.o = b
d.w = k
d.q = k
assert k.o.p.u.q.txt == "k"