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

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

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

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

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

k = A("k")
f = B("f")
m = C("m")
g = D("g")
l = E("l")
d = A("d")
h = E("h")

k.y = g
k.v = f
f.p = m
f.v = m
f.y = l
m.q = g
m.t = h
g.r = l
g.v = f
g.t = m
g.x = m
l.r = h
l.v = h
l.s = g
l.w = k
d.y = g
d.v = f
h.r = l
h.v = l
h.s = g
h.w = d
assert l.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.v: B = None
        self.txt = txt

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

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

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

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

k = A("k")
f = B("f")
m = C("m")
g = D("g")
l = E("l")
d = A("d")
h = E("h")

k.y = g
k.v = f
f.p = m
f.v = m
f.y = l
m.q = g
m.t = h
g.r = l
g.v = f
g.t = m
g.x = m
l.r = h
l.v = h
l.s = g
l.w = k
d.y = g
d.v = f
h.r = l
h.v = l
h.s = g
h.w = d
assert l.v.s.v.txt == "f"