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

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

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

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

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

b = A("b")
g = B("g")
c = C("c")
k = D("k")
e = E("e")
d = E("d")
l = B("l")
i = A("i")
m = C("m")

b.s = i
b.t = e
b.q = k
g.z = k
g.o = l
g.x = b
c.z = i
c.s = m
k.r = c
k.w = m
k.v = m
k.p = e
e.q = l
d.q = g
l.z = k
l.o = g
l.x = i
i.s = b
i.t = d
i.q = k
m.z = b
m.s = c
assert k.p.q.x.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: E = None
        self.q: D = None
        self.txt = txt

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

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

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

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

b = A("b")
g = B("g")
c = C("c")
k = D("k")
e = E("e")
d = E("d")
l = B("l")
i = A("i")
m = C("m")

b.s = i
b.t = e
b.q = k
g.z = k
g.o = l
g.x = b
c.z = i
c.s = m
k.r = c
k.w = m
k.v = m
k.p = e
e.q = l
d.q = g
l.z = k
l.o = g
l.x = i
i.s = b
i.t = d
i.q = k
m.z = b
m.s = c
assert k.p.q.x.q.r.txt == "c"