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.txt = txt

h = A("h")
g = B("g")
i = A("i")
n = A("n")
k = B("k")
d = A("d")
c = B("c")

h.w = n
h.o = n
g.v = h
i.w = d
i.o = n
n.w = i
n.o = d
k.v = n
d.w = h
d.o = n
c.v = i
assert c.v.w.w.o.w.w.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.txt = txt

h = A("h")
g = B("g")
i = A("i")
n = A("n")
k = B("k")
d = A("d")
c = B("c")

h.w = n
h.o = n
g.v = h
i.w = d
i.o = n
n.w = i
n.o = d
k.v = n
d.w = h
d.o = n
c.v = i
assert c.v.w.w.o.w.w.txt == "d"