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

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

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

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

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

e.x = a
e.w = k
f.u = n
f.x = g
f.z = g
n.q = a
a.o = n
a.s = g
a.x = k
a.z = h
g.u = n
g.x = f
g.z = f
k.x = a
k.w = h
h.x = a
h.w = e
assert k.w.w.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.w: A = None
        self.txt = txt

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

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

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

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

e.x = a
e.w = k
f.u = n
f.x = g
f.z = g
n.q = a
a.o = n
a.s = g
a.x = k
a.z = h
g.u = n
g.x = f
g.z = f
k.x = a
k.w = h
h.x = a
h.w = e
assert k.w.w.x.o.txt == "n"