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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.s: B = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.s: B = None
        self.txt = txt

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

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

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

m.p = e
m.v = g
m.r = i
c.u = g
c.s = h
i.v = m
g.q = l
g.w = n
n.v = a
e.u = g
e.s = c
h.u = g
h.s = c
l.p = h
l.v = g
l.r = n
a.p = c
a.v = g
a.r = i
assert c.u.w.v.v.w.v.r.v.r.txt == "i"