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

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

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

m = A("m")
f = B("f")
n = C("n")
e = C("e")

m.y = n
m.t = f
f.s = n
f.w = m
n.q = e
n.x = f
n.p = f
e.q = n
e.x = f
e.p = f
assert m.t.w.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: B = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
n = C("n")
e = C("e")

m.y = n
m.t = f
f.s = n
f.w = m
n.q = e
n.x = f
n.p = f
e.q = n
e.x = f
e.p = f
assert m.t.w.t.s.txt == "n"