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

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

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

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

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

g = A("g")
h = B("h")
n = C("n")
i = D("i")
m = E("m")
b = B("b")
j = D("j")
l = B("l")
k = C("k")
c = E("c")

g.v = n
h.r = g
n.r = c
n.z = m
i.x = m
i.w = g
m.u = l
m.z = n
b.r = g
j.x = c
j.w = g
l.r = g
k.r = c
k.z = m
c.u = l
c.z = k
assert j.w.v.z.z.r.z.r.u.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

g = A("g")
h = B("h")
n = C("n")
i = D("i")
m = E("m")
b = B("b")
j = D("j")
l = B("l")
k = C("k")
c = E("c")

g.v = n
h.r = g
n.r = c
n.z = m
i.x = m
i.w = g
m.u = l
m.z = n
b.r = g
j.x = c
j.w = g
l.r = g
k.r = c
k.z = m
c.u = l
c.z = k
assert j.w.v.z.z.r.z.r.u.r.v.txt == "n"