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

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

n = A("n")
f = B("f")
d = B("d")
a = B("a")
m = A("m")
j = A("j")
l = A("l")
i = B("i")

n.y = d
n.u = i
f.v = l
d.v = n
a.v = j
m.y = f
m.u = d
j.y = f
j.u = f
l.y = f
l.u = a
i.v = j
assert l.u.v.y.v.u.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: B = None
        self.txt = txt

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

n = A("n")
f = B("f")
d = B("d")
a = B("a")
m = A("m")
j = A("j")
l = A("l")
i = B("i")

n.y = d
n.u = i
f.v = l
d.v = n
a.v = j
m.y = f
m.u = d
j.y = f
j.u = f
l.y = f
l.u = a
i.v = j
assert l.u.v.y.v.u.v.y.v.txt == "l"