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

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

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

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

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

k.o = g
k.s = a
a.x = g
a.v = b
i.w = d
h.p = a
d.w = i
m.p = a
f.o = a
f.s = g
b.p = a
e.o = a
e.s = g
g.x = a
g.v = h
assert e.s.x.x.v.p.v.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: B = None
        self.txt = txt

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

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

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

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

k.o = g
k.s = a
a.x = g
a.v = b
i.w = d
h.p = a
d.w = i
m.p = a
f.o = a
f.s = g
b.p = a
e.o = a
e.s = g
g.x = a
g.v = h
assert e.s.x.x.v.p.v.p.x.txt == "g"