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

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

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

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

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

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

h.z = b
d.p = b
d.u = b
n.o = h
m.v = c
m.o = g
m.q = a
m.r = j
b.x = c
c.o = j
j.z = b
a.v = n
a.o = g
a.q = m
a.r = h
g.p = b
g.u = b
l.p = b
l.u = b
assert d.u.x.o.z.x.o.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

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

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

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

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

h.z = b
d.p = b
d.u = b
n.o = h
m.v = c
m.o = g
m.q = a
m.r = j
b.x = c
c.o = j
j.z = b
a.v = n
a.o = g
a.q = m
a.r = h
g.p = b
g.u = b
l.p = b
l.u = b
assert d.u.x.o.z.x.o.z.x.txt == "c"