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

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

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

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

n.v = m
a.x = j
a.z = m
a.w = n
m.t = n
j.t = n
assert a.w.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

n.v = m
a.x = j
a.z = m
a.w = n
m.t = n
j.t = n
assert a.w.v.t.txt == "n"