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

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

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

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

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

c = A("c")
n = B("n")
a = C("a")
m = D("m")
d = E("d")
b = E("b")
k = C("k")

c.o = m
c.u = m
c.p = m
c.y = n
n.u = m
n.w = c
n.o = k
a.y = c
a.u = m
m.r = d
m.x = c
d.r = c
d.w = m
d.q = b
b.r = c
b.w = m
b.q = d
k.y = c
k.u = m
assert a.y.y.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.y: B = None
        self.u: D = None
        self.p: D = None
        self.txt = txt

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

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

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

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

c = A("c")
n = B("n")
a = C("a")
m = D("m")
d = E("d")
b = E("b")
k = C("k")

c.o = m
c.u = m
c.p = m
c.y = n
n.u = m
n.w = c
n.o = k
a.y = c
a.u = m
m.r = d
m.x = c
d.r = c
d.w = m
d.q = b
b.r = c
b.w = m
b.q = d
k.y = c
k.u = m
assert a.y.y.u.r.txt == "d"