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

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

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

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

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

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

e.r = k
e.v = j
l.p = e
g.t = h
h.x = e
h.q = l
h.v = l
j.x = d
j.s = l
k.r = e
k.v = j
d.x = e
d.q = l
d.v = l
assert e.v.s.p.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: E = None
        self.txt = txt

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

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

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

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

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

e.r = k
e.v = j
l.p = e
g.t = h
h.x = e
h.q = l
h.v = l
j.x = d
j.s = l
k.r = e
k.v = j
d.x = e
d.q = l
d.v = l
assert e.v.s.p.v.s.txt == "l"