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

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

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

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

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

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

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

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

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

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

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

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

k.u = n
d.r = k
g.v = d
g.q = d
n.y = g
n.u = d
l.s = g
l.p = g
l.q = g
l.v = d
l.x = n
assert d.r.u.u.r.txt == "k"