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

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

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

l.w = c
l.v = g
g.z = f
g.p = n
h.z = g
h.p = c
c.w = i
c.v = f
n.w = i
n.v = f
f.z = h
f.p = c
i.w = m
i.v = f
m.w = i
m.v = f
assert i.w.w.w.w.v.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: B = None
        self.txt = txt

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

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

l.w = c
l.v = g
g.z = f
g.p = n
h.z = g
h.p = c
c.w = i
c.v = f
n.w = i
n.v = f
f.z = h
f.p = c
i.w = m
i.v = f
m.w = i
m.v = f
assert i.w.w.w.w.v.p.v.p.txt == "c"