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

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

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

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

m = A("m")
g = B("g")
h = C("h")
k = D("k")
j = D("j")
i = A("i")
a = A("a")
c = B("c")
n = A("n")

m.o = h
g.x = m
g.v = j
g.o = j
g.s = h
h.s = c
h.w = c
k.p = h
j.p = h
i.o = h
a.o = h
c.x = m
c.v = k
c.o = k
c.s = h
n.o = h
assert a.o.w.x.o.s.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

m = A("m")
g = B("g")
h = C("h")
k = D("k")
j = D("j")
i = A("i")
a = A("a")
c = B("c")
n = A("n")

m.o = h
g.x = m
g.v = j
g.o = j
g.s = h
h.s = c
h.w = c
k.p = h
j.p = h
i.o = h
a.o = h
c.x = m
c.v = k
c.o = k
c.s = h
n.o = h
assert a.o.w.x.o.s.x.o.txt == "h"