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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: A = None
        self.q: A = None
        self.t: D = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: A = None
        self.q: A = None
        self.t: D = None
        self.txt = txt

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

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

h.w = a
h.o = c
m.t = b
m.y = a
m.p = a
m.v = h
a.s = b
a.v = b
a.q = h
a.t = k
k.p = g
c.w = a
c.o = h
f.t = h
f.v = h
f.y = a
f.p = a
i.p = m
b.w = a
b.o = h
g.t = c
g.y = a
g.p = a
g.v = h
assert m.v.w.s.o.w.s.o.txt == "h"