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

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

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

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

k.r = f
k.v = n
m.q = n
m.v = n
f.s = k
f.x = k
f.q = k
n.q = m
n.v = m
assert k.v.q.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.v: B = None
        self.txt = txt

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

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

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

k.r = f
k.v = n
m.q = n
m.v = n
f.s = k
f.x = k
f.q = k
n.q = m
n.v = m
assert k.v.q.v.q.txt == "m"