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

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: A = None
        self.w: C = None
        self.u: A = None
        self.r: B = None
        self.txt = txt

m = A("m")
g = B("g")
h = C("h")
d = D("d")
l = E("l")
e = A("e")
n = E("n")
j = E("j")

m.u = h
g.r = j
g.t = h
h.r = g
h.v = n
d.o = l
l.x = d
l.z = e
l.w = h
l.u = m
l.r = g
e.u = h
n.x = d
n.z = e
n.w = h
n.u = m
n.r = g
j.x = d
j.z = m
j.u = m
j.w = h
j.r = g
assert e.u.v.z.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: A = None
        self.w: C = None
        self.u: A = None
        self.r: B = None
        self.txt = txt

m = A("m")
g = B("g")
h = C("h")
d = D("d")
l = E("l")
e = A("e")
n = E("n")
j = E("j")

m.u = h
g.r = j
g.t = h
h.r = g
h.v = n
d.o = l
l.x = d
l.z = e
l.w = h
l.u = m
l.r = g
e.u = h
n.x = d
n.z = e
n.w = h
n.u = m
n.r = g
j.x = d
j.z = m
j.u = m
j.w = h
j.r = g
assert e.u.v.z.u.v.txt == "n"