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

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

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

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

m.p = b
b.w = m
b.t = n
b.v = n
n.y = b
assert b.w.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

m.p = b
b.w = m
b.t = n
b.v = n
n.y = b
assert b.w.p.t.txt == "n"