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

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

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.o: D = None
        self.q: D = None
        self.z: C = None
        self.txt = txt

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

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

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

c.s = e
m.r = b
m.w = e
m.p = c
m.x = c
e.w = k
e.z = k
e.o = b
e.q = b
b.p = e
b.w = e
b.v = m
b.q = g
g.z = b
g.q = b
g.u = m
g.y = k
g.s = k
k.w = e
k.z = e
k.o = b
k.q = b
assert k.w.q.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.o: D = None
        self.q: D = None
        self.z: C = None
        self.txt = txt

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

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

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

c.s = e
m.r = b
m.w = e
m.p = c
m.x = c
e.w = k
e.z = k
e.o = b
e.q = b
b.p = e
b.w = e
b.v = m
b.q = g
g.z = b
g.q = b
g.u = m
g.y = k
g.s = k
k.w = e
k.z = e
k.o = b
k.q = b
assert k.w.q.q.u.txt == "m"