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

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

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

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

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

l.s = h
l.o = h
l.q = i
m.q = h
h.p = i
h.v = g
f.o = n
k.o = i
i.p = n
i.v = l
d.q = i
b.o = h
g.s = i
g.q = n
g.o = n
n.p = i
n.v = l
assert k.o.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: C = None
        self.o: C = None
        self.txt = txt

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

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

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

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

l.s = h
l.o = h
l.q = i
m.q = h
h.p = i
h.v = g
f.o = n
k.o = i
i.p = n
i.v = l
d.q = i
b.o = h
g.s = i
g.q = n
g.o = n
n.p = i
n.v = l
assert k.o.p.p.p.txt == "n"