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

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

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

e = A("e")
i = B("i")
m = C("m")
l = A("l")
a = C("a")
n = C("n")
c = B("c")

e.p = l
e.r = i
i.w = a
m.q = i
m.t = c
m.v = l
l.p = e
l.r = i
a.q = i
a.t = i
a.v = e
n.q = i
n.t = c
n.v = e
c.w = n
assert a.v.r.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.r: B = None
        self.txt = txt

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

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

e = A("e")
i = B("i")
m = C("m")
l = A("l")
a = C("a")
n = C("n")
c = B("c")

e.p = l
e.r = i
i.w = a
m.q = i
m.t = c
m.v = l
l.p = e
l.r = i
a.q = i
a.t = i
a.v = e
n.q = i
n.t = c
n.v = e
c.w = n
assert a.v.r.w.v.txt == "e"