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

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

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

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

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

k = A("k")
i = B("i")
n = C("n")
c = D("c")
a = E("a")

k.u = c
i.r = a
n.v = c
n.p = c
c.s = n
c.x = k
a.r = i
a.u = n
a.x = n
a.y = c
assert i.r.r.r.r.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: E = None
        self.txt = txt

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

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

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

k = A("k")
i = B("i")
n = C("n")
c = D("c")
a = E("a")

k.u = c
i.r = a
n.v = c
n.p = c
c.s = n
c.x = k
a.r = i
a.u = n
a.x = n
a.y = c
assert i.r.r.r.r.r.txt == "a"