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

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

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

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

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

j = A("j")
n = B("n")
l = C("l")
i = D("i")
a = E("a")
k = A("k")
h = D("h")

j.x = k
j.r = n
n.v = i
n.z = j
l.p = i
l.t = a
i.v = l
i.y = j
i.x = k
a.s = n
k.x = j
k.r = n
h.v = l
h.y = k
h.x = k
assert k.x.r.v.x.r.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: B = None
        self.txt = txt

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

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

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

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

j = A("j")
n = B("n")
l = C("l")
i = D("i")
a = E("a")
k = A("k")
h = D("h")

j.x = k
j.r = n
n.v = i
n.z = j
l.p = i
l.t = a
i.v = l
i.y = j
i.x = k
a.s = n
k.x = j
k.r = n
h.v = l
h.y = k
h.x = k
assert k.x.r.v.x.r.v.y.txt == "j"