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

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

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

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

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

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

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

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

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