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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: B = None
        self.w: B = None
        self.txt = txt

l = A("l")
g = B("g")
k = C("k")
j = D("j")
f = E("f")

l.q = j
l.u = k
g.x = l
k.t = g
k.q = j
k.z = f
k.s = l
j.r = g
j.q = g
j.v = f
f.r = k
f.u = g
f.w = g
assert k.q.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: B = None
        self.w: B = None
        self.txt = txt

l = A("l")
g = B("g")
k = C("k")
j = D("j")
f = E("f")

l.q = j
l.u = k
g.x = l
k.t = g
k.q = j
k.z = f
k.s = l
j.r = g
j.q = g
j.v = f
f.r = k
f.u = g
f.w = g
assert k.q.v.r.txt == "k"