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

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

b = A("b")
f = B("f")
j = A("j")
g = A("g")
m = A("m")
e = A("e")
n = B("n")
l = A("l")
k = B("k")
a = A("a")

b.v = g
f.y = n
j.v = b
g.v = l
m.v = a
e.v = a
n.y = k
l.v = g
k.y = n
a.v = m
assert f.y.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

b = A("b")
f = B("f")
j = A("j")
g = A("g")
m = A("m")
e = A("e")
n = B("n")
l = A("l")
k = B("k")
a = A("a")

b.v = g
f.y = n
j.v = b
g.v = l
m.v = a
e.v = a
n.y = k
l.v = g
k.y = n
a.v = m
assert f.y.y.y.y.y.y.y.y.txt == "k"