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

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

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

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: B = None
        self.txt = txt

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

n = A("n")
g = B("g")
a = C("a")
l = D("l")
c = E("c")
f = D("f")
e = A("e")
m = C("m")

n.v = c
n.u = c
g.r = f
g.u = c
a.w = n
a.v = g
l.z = c
l.p = g
c.r = e
f.z = c
f.p = g
e.v = c
e.u = c
m.w = n
m.v = g
assert g.u.r.u.r.v.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.u: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: B = None
        self.txt = txt

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

n = A("n")
g = B("g")
a = C("a")
l = D("l")
c = E("c")
f = D("f")
e = A("e")
m = C("m")

n.v = c
n.u = c
g.r = f
g.u = c
a.w = n
a.v = g
l.z = c
l.p = g
c.r = e
f.z = c
f.p = g
e.v = c
e.u = c
m.w = n
m.v = g
assert g.u.r.u.r.v.r.u.txt == "c"