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

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.y: D = None
        self.p: B = None
        self.z: A = None
        self.r: D = 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.w: B = None
        self.txt = txt

n = A("n")
c = B("c")
a = C("a")
j = D("j")
g = E("g")
i = A("i")

n.u = i
n.o = c
n.y = a
n.p = a
n.t = g
c.q = g
c.u = a
c.y = j
a.t = c
a.p = c
a.y = j
a.r = j
a.z = i
j.o = g
g.w = c
i.u = n
i.o = c
i.y = a
i.p = a
i.t = g
assert a.z.y.y.o.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: B = None
        self.y: C = None
        self.p: C = None
        self.t: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.y: D = None
        self.p: B = None
        self.z: A = None
        self.r: D = 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.w: B = None
        self.txt = txt

n = A("n")
c = B("c")
a = C("a")
j = D("j")
g = E("g")
i = A("i")

n.u = i
n.o = c
n.y = a
n.p = a
n.t = g
c.q = g
c.u = a
c.y = j
a.t = c
a.p = c
a.y = j
a.r = j
a.z = i
j.o = g
g.w = c
i.u = n
i.o = c
i.y = a
i.p = a
i.t = g
assert a.z.y.y.o.w.y.txt == "j"