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

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

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

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

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

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

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

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

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

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

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