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

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

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

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

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

k = A("k")
g = B("g")
n = C("n")
b = D("b")
h = E("h")
i = E("i")
m = C("m")
c = D("c")

k.p = h
k.o = c
k.q = n
k.y = g
g.z = h
g.q = b
n.r = g
b.q = g
h.p = c
h.r = i
h.t = i
h.x = k
h.w = m
i.p = c
i.r = h
i.t = h
i.x = k
i.w = n
m.r = g
c.q = g
assert n.r.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.o: D = None
        self.q: C = None
        self.y: B = None
        self.txt = txt

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

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

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

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

k = A("k")
g = B("g")
n = C("n")
b = D("b")
h = E("h")
i = E("i")
m = C("m")
c = D("c")

k.p = h
k.o = c
k.q = n
k.y = g
g.z = h
g.q = b
n.r = g
b.q = g
h.p = c
h.r = i
h.t = i
h.x = k
h.w = m
i.p = c
i.r = h
i.t = h
i.x = k
i.w = n
m.r = g
c.q = g
assert n.r.q.q.q.q.q.txt == "b"