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

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

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

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

a.q = m
a.t = m
m.t = b
m.p = b
b.x = m
b.t = m
b.v = a
assert m.p.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: B = None
        self.txt = txt

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

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

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

a.q = m
a.t = m
m.t = b
m.p = b
b.x = m
b.t = m
b.v = a
assert m.p.v.t.txt == "m"