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

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

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

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

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

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

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