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

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

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

m = A("m")
d = B("d")
f = C("f")
a = C("a")
b = A("b")
n = B("n")
e = A("e")

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

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

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

m = A("m")
d = B("d")
f = C("f")
a = C("a")
b = A("b")
n = B("n")
e = A("e")

m.y = d
m.w = f
d.s = a
d.q = b
f.p = e
f.v = e
a.p = b
a.v = b
b.y = n
b.w = f
n.s = a
n.q = e
e.y = n
e.w = a
assert e.w.v.y.s.v.w.v.txt == "e"