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

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

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

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

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

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

i.y = f
j.s = f
j.v = i
l.y = n
g.y = f
m.y = e
n.s = j
n.v = l
f.s = n
f.v = l
a.s = e
a.v = i
e.s = j
e.v = g
assert f.s.s.s.txt == "f"