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

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

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

k = A("k")
m = B("m")
a = C("a")

k.u = a
m.v = a
a.q = m
assert k.u.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

k = A("k")
m = B("m")
a = C("a")

k.u = a
m.v = a
a.q = m
assert k.u.q.v.txt == "a"