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

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

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

l = A("l")
m = B("m")
e = C("e")
n = C("n")
d = A("d")
h = C("h")
k = B("k")
f = C("f")
a = B("a")
i = B("i")

l.y = d
l.v = f
m.v = d
m.x = n
e.s = l
n.s = d
d.y = l
d.v = n
h.s = l
k.v = l
k.x = f
f.s = d
a.v = d
a.x = f
i.v = d
i.x = h
assert l.y.y.v.s.v.s.y.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: C = None
        self.txt = txt

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

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

l = A("l")
m = B("m")
e = C("e")
n = C("n")
d = A("d")
h = C("h")
k = B("k")
f = C("f")
a = B("a")
i = B("i")

l.y = d
l.v = f
m.v = d
m.x = n
e.s = l
n.s = d
d.y = l
d.v = n
h.s = l
k.v = l
k.x = f
f.s = d
a.v = d
a.x = f
i.v = d
i.x = h
assert l.y.y.v.s.v.s.y.v.s.txt == "d"