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

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

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

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

f = A("f")
g = B("g")
b = C("b")
k = D("k")
n = D("n")
e = B("e")
m = D("m")

f.p = m
f.w = e
f.r = b
f.u = b
g.u = n
g.z = b
g.s = b
b.o = f
b.s = f
b.v = g
k.p = g
k.u = g
k.w = m
k.o = b
n.p = g
n.u = g
n.w = k
n.o = b
e.u = m
e.z = b
e.s = b
m.p = g
m.u = e
m.w = n
m.o = b
assert k.o.o.p.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.w: B = None
        self.r: C = None
        self.u: C = None
        self.txt = txt

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

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

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

f = A("f")
g = B("g")
b = C("b")
k = D("k")
n = D("n")
e = B("e")
m = D("m")

f.p = m
f.w = e
f.r = b
f.u = b
g.u = n
g.z = b
g.s = b
b.o = f
b.s = f
b.v = g
k.p = g
k.u = g
k.w = m
k.o = b
n.p = g
n.u = g
n.w = k
n.o = b
e.u = m
e.z = b
e.s = b
m.p = g
m.u = e
m.w = n
m.o = b
assert k.o.o.p.o.v.txt == "g"