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

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

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

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

m = A("m")
j = B("j")
l = C("l")
d = D("d")
f = D("f")
a = B("a")
k = A("k")
e = B("e")

m.p = k
m.o = k
j.u = d
j.x = m
j.w = a
j.o = l
l.x = f
l.q = k
d.z = a
f.z = e
a.u = f
a.x = m
a.w = j
a.o = l
k.p = m
k.o = m
e.u = f
e.x = m
e.w = a
e.o = l
assert m.o.p.p.o.p.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: A = None
        self.txt = txt

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

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

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

m = A("m")
j = B("j")
l = C("l")
d = D("d")
f = D("f")
a = B("a")
k = A("k")
e = B("e")

m.p = k
m.o = k
j.u = d
j.x = m
j.w = a
j.o = l
l.x = f
l.q = k
d.z = a
f.z = e
a.u = f
a.x = m
a.w = j
a.o = l
k.p = m
k.o = m
e.u = f
e.x = m
e.w = a
e.o = l
assert m.o.p.p.o.p.o.o.txt == "k"