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

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

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

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

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

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

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

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

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

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

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