class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.r: A = 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.z: D = None
        self.y: A = None
        self.txt = txt

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

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

a = A("a")
n = B("n")
i = C("i")
h = D("h")
j = E("j")
k = A("k")
d = E("d")
e = A("e")
c = B("c")

a.v = d
a.r = e
n.r = d
i.z = h
i.y = a
h.w = i
h.v = a
j.w = c
k.v = j
k.r = a
d.w = c
e.v = j
e.r = a
c.r = j
assert a.r.v.w.r.w.r.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.r: A = 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.z: D = None
        self.y: A = None
        self.txt = txt

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

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

a = A("a")
n = B("n")
i = C("i")
h = D("h")
j = E("j")
k = A("k")
d = E("d")
e = A("e")
c = B("c")

a.v = d
a.r = e
n.r = d
i.z = h
i.y = a
h.w = i
h.v = a
j.w = c
k.v = j
k.r = a
d.w = c
e.v = j
e.r = a
c.r = j
assert a.r.v.w.r.w.r.w.r.w.txt == "c"