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

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

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

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

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

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

h.z = k
h.u = i
h.p = i
k.u = c
k.w = f
j.r = k
j.x = n
f.q = c
f.v = j
f.z = k
c.q = f
n.r = k
n.x = j
i.z = k
i.u = g
i.p = g
g.z = k
g.u = i
g.p = h
assert n.r.u.q.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: A = None
        self.p: A = None
        self.txt = txt

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

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

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

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

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

h.z = k
h.u = i
h.p = i
k.u = c
k.w = f
j.r = k
j.x = n
f.q = c
f.v = j
f.z = k
c.q = f
n.r = k
n.x = j
i.z = k
i.u = g
i.p = g
g.z = k
g.u = i
g.p = h
assert n.r.u.q.z.u.txt == "c"