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

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

g = A("g")
i = B("i")
h = A("h")
n = B("n")
m = A("m")
f = B("f")
d = B("d")
k = B("k")
l = A("l")

g.v = m
g.o = m
i.w = n
h.v = l
h.o = g
n.w = f
m.v = l
m.o = l
f.w = k
d.w = i
k.w = f
l.v = h
l.o = h
assert f.w.w.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.o: A = None
        self.txt = txt

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

g = A("g")
i = B("i")
h = A("h")
n = B("n")
m = A("m")
f = B("f")
d = B("d")
k = B("k")
l = A("l")

g.v = m
g.o = m
i.w = n
h.v = l
h.o = g
n.w = f
m.v = l
m.o = l
f.w = k
d.w = i
k.w = f
l.v = h
l.o = h
assert f.w.w.w.w.w.w.w.w.txt == "f"