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

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

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

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

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

n = A("n")
l = B("l")
j = C("j")
i = D("i")
m = E("m")
k = D("k")
f = E("f")

n.q = l
n.s = j
l.p = j
l.u = m
l.o = n
j.p = l
j.s = i
i.w = k
m.v = n
m.w = j
k.w = i
f.v = n
f.w = j
assert k.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: C = None
        self.txt = txt

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

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

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

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

n = A("n")
l = B("l")
j = C("j")
i = D("i")
m = E("m")
k = D("k")
f = E("f")

n.q = l
n.s = j
l.p = j
l.u = m
l.o = n
j.p = l
j.s = i
i.w = k
m.v = n
m.w = j
k.w = i
f.v = n
f.w = j
assert k.w.w.w.txt == "i"