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

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

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

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

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

c.p = f
c.u = l
a.p = g
a.o = b
k.v = l
k.s = l
k.o = f
m.q = n
m.o = l
m.p = l
m.x = b
l.q = a
l.o = m
l.p = m
l.x = k
n.p = i
n.o = i
f.p = g
f.o = i
i.v = m
i.o = n
i.s = l
g.v = l
g.s = l
g.o = n
b.v = l
b.o = a
b.s = m
assert l.x.o.p.o.o.o.p.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: D = None
        self.txt = txt

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

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

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

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

c.p = f
c.u = l
a.p = g
a.o = b
k.v = l
k.s = l
k.o = f
m.q = n
m.o = l
m.p = l
m.x = b
l.q = a
l.o = m
l.p = m
l.x = k
n.p = i
n.o = i
f.p = g
f.o = i
i.v = m
i.o = n
i.s = l
g.v = l
g.s = l
g.o = n
b.v = l
b.o = a
b.s = m
assert l.x.o.p.o.o.o.p.o.o.txt == "i"