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

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

b = A("b")
i = B("i")
a = A("a")
l = B("l")
k = B("k")
d = A("d")
j = B("j")
f = A("f")

b.s = a
i.v = b
a.s = d
l.v = b
k.v = f
d.s = a
j.v = f
f.s = d
assert f.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

b = A("b")
i = B("i")
a = A("a")
l = B("l")
k = B("k")
d = A("d")
j = B("j")
f = A("f")

b.s = a
i.v = b
a.s = d
l.v = b
k.v = f
d.s = a
j.v = f
f.s = d
assert f.s.s.s.s.s.txt == "d"