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

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

a = A("a")
i = B("i")
f = B("f")
l = A("l")
g = B("g")
k = A("k")

a.v = k
i.t = g
i.u = g
f.t = i
f.u = g
l.v = k
g.t = f
g.u = f
k.v = l
assert a.v.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.t: B = None
        self.u: B = None
        self.txt = txt

a = A("a")
i = B("i")
f = B("f")
l = A("l")
g = B("g")
k = A("k")

a.v = k
i.t = g
i.u = g
f.t = i
f.u = g
l.v = k
g.t = f
g.u = f
k.v = l
assert a.v.v.v.v.v.v.txt == "l"