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

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

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

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

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

c = A("c")
h = B("h")
g = C("g")
k = D("k")
l = E("l")
j = B("j")
n = A("n")

c.v = k
h.p = k
g.s = l
k.z = g
k.x = c
l.v = g
j.p = k
n.v = k
assert l.v.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

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

c = A("c")
h = B("h")
g = C("g")
k = D("k")
l = E("l")
j = B("j")
n = A("n")

c.v = k
h.p = k
g.s = l
k.z = g
k.x = c
l.v = g
j.p = k
n.v = k
assert l.v.s.v.s.txt == "l"