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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: A = None
        self.s: D = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: A = None
        self.s: D = None
        self.txt = txt

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

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