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

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: A = None
        self.y: D = None
        self.w: A = None
        self.z: A = None
        self.txt = txt

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

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

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

j = A("j")
a = B("a")
l = C("l")
n = D("n")
k = E("k")

j.q = n
a.q = j
a.u = j
a.w = j
a.z = j
a.y = n
l.o = k
l.p = a
n.o = a
k.v = l
k.t = j
assert k.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: A = None
        self.y: D = None
        self.w: A = None
        self.z: A = None
        self.txt = txt

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

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

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

j = A("j")
a = B("a")
l = C("l")
n = D("n")
k = E("k")

j.q = n
a.q = j
a.u = j
a.w = j
a.z = j
a.y = n
l.o = k
l.p = a
n.o = a
k.v = l
k.t = j
assert k.v.o.v.txt == "l"