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

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

d = A("d")
l = B("l")
a = A("a")
n = B("n")
e = A("e")
b = B("b")
c = A("c")
f = A("f")

d.u = b
d.v = n
l.z = e
a.u = b
a.v = b
n.z = f
e.u = b
e.v = l
b.z = c
c.u = b
c.v = n
f.u = n
f.v = l
assert l.z.v.z.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: B = None
        self.txt = txt

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

d = A("d")
l = B("l")
a = A("a")
n = B("n")
e = A("e")
b = B("b")
c = A("c")
f = A("f")

d.u = b
d.v = n
l.z = e
a.u = b
a.v = b
n.z = f
e.u = b
e.v = l
b.z = c
c.u = b
c.v = n
f.u = n
f.v = l
assert l.z.v.z.v.z.v.txt == "l"