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

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

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

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

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

a = A("a")
l = B("l")
d = C("d")
e = D("e")
g = E("g")
k = E("k")

a.q = l
a.r = e
a.x = d
l.u = e
l.q = e
d.u = a
d.x = g
e.v = l
e.s = l
e.z = l
e.p = l
e.r = d
g.z = d
g.q = d
k.z = d
k.q = d
assert l.q.r.u.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: D = None
        self.x: C = None
        self.txt = txt

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

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

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

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

a = A("a")
l = B("l")
d = C("d")
e = D("e")
g = E("g")
k = E("k")

a.q = l
a.r = e
a.x = d
l.u = e
l.q = e
d.u = a
d.x = g
e.v = l
e.s = l
e.z = l
e.p = l
e.r = d
g.z = d
g.q = d
k.z = d
k.q = d
assert l.q.r.u.r.r.txt == "d"