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

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

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

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

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

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

a.v = g
e.w = k
k.w = n
i.w = e
b.v = g
g.v = j
n.w = i
l.v = g
f.v = l
j.v = a
assert f.v.v.v.v.v.txt == "g"