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

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

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

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

f = A("f")
d = B("d")
k = C("k")
n = D("n")
b = D("b")
h = B("h")
a = A("a")
c = D("c")
m = A("m")

f.p = a
f.v = k
f.o = m
f.w = d
d.w = k
d.o = n
d.t = f
k.w = d
k.u = d
k.o = b
k.r = f
n.p = k
b.p = k
h.w = k
h.o = b
h.t = f
a.p = m
a.o = m
a.v = k
a.w = d
c.p = k
m.p = a
m.v = k
m.o = f
m.w = d
assert n.p.o.p.r.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: C = None
        self.o: A = None
        self.w: B = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
k = C("k")
n = D("n")
b = D("b")
h = B("h")
a = A("a")
c = D("c")
m = A("m")

f.p = a
f.v = k
f.o = m
f.w = d
d.w = k
d.o = n
d.t = f
k.w = d
k.u = d
k.o = b
k.r = f
n.p = k
b.p = k
h.w = k
h.o = b
h.t = f
a.p = m
a.o = m
a.v = k
a.w = d
c.p = k
m.p = a
m.v = k
m.o = f
m.w = d
assert n.p.o.p.r.w.t.txt == "f"