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

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

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

b = A("b")
k = B("k")
c = C("c")
a = B("a")

b.o = k
b.r = a
b.p = c
k.t = b
k.q = c
c.w = b
c.v = b
c.z = b
a.t = b
a.q = c
assert k.t.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.r: B = None
        self.p: C = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
c = C("c")
a = B("a")

b.o = k
b.r = a
b.p = c
k.t = b
k.q = c
c.w = b
c.v = b
c.z = b
a.t = b
a.q = c
assert k.t.r.q.txt == "c"