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

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.y: A = None
        self.u: E = None
        self.x: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

h.z = c
h.x = c
i.o = j
i.u = j
i.x = j
i.y = c
m.z = n
m.r = j
n.s = i
j.w = k
j.v = k
j.y = d
j.u = i
j.x = f
k.s = i
f.z = k
f.r = j
d.z = h
d.x = h
c.z = d
c.x = h
assert n.s.x.x.z.s.x.v.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.y: A = None
        self.u: E = None
        self.x: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

h.z = c
h.x = c
i.o = j
i.u = j
i.x = j
i.y = c
m.z = n
m.r = j
n.s = i
j.w = k
j.v = k
j.y = d
j.u = i
j.x = f
k.s = i
f.z = k
f.r = j
d.z = h
d.x = h
c.z = d
c.x = h
assert n.s.x.x.z.s.x.v.s.x.txt == "j"