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

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

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

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

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

n = A("n")
c = B("c")
f = C("f")
m = D("m")
k = E("k")

n.q = m
n.y = m
n.r = f
c.p = n
f.t = n
f.o = n
f.s = m
f.u = k
m.v = n
m.u = c
k.p = m
k.x = f
assert m.v.r.u.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.r: C = None
        self.y: D = None
        self.txt = txt

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

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

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

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

n = A("n")
c = B("c")
f = C("f")
m = D("m")
k = E("k")

n.q = m
n.y = m
n.r = f
c.p = n
f.t = n
f.o = n
f.s = m
f.u = k
m.v = n
m.u = c
k.p = m
k.x = f
assert m.v.r.u.x.s.txt == "m"