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

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

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

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

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

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

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

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

m.v = a
j.q = m
a.p = j
assert j.q.v.p.txt == "j"