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

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

g = A("g")
i = B("i")
f = A("f")
b = A("b")
j = A("j")
c = A("c")
a = B("a")
h = B("h")
k = A("k")
m = B("m")

g.w = c
g.o = j
i.v = c
i.w = c
f.w = g
f.o = c
b.w = c
b.o = g
j.w = c
j.o = b
c.w = g
c.o = g
a.v = g
a.w = c
h.v = g
h.w = g
k.w = g
k.o = j
m.v = f
m.w = g
assert h.v.w.o.o.w.o.w.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: A = None
        self.txt = txt

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

g = A("g")
i = B("i")
f = A("f")
b = A("b")
j = A("j")
c = A("c")
a = B("a")
h = B("h")
k = A("k")
m = B("m")

g.w = c
g.o = j
i.v = c
i.w = c
f.w = g
f.o = c
b.w = c
b.o = g
j.w = c
j.o = b
c.w = g
c.o = g
a.v = g
a.w = c
h.v = g
h.w = g
k.w = g
k.o = j
m.v = f
m.w = g
assert h.v.w.o.o.w.o.w.o.o.o.txt == "b"