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

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

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

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

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

n.o = h
n.w = k
n.s = a
n.p = a
a.x = k
k.x = n
k.o = n
k.q = h
h.r = a
h.v = k
h.p = k
assert k.o.o.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.w: C = None
        self.s: B = None
        self.p: B = None
        self.txt = txt

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

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

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

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

n.o = h
n.w = k
n.s = a
n.p = a
a.x = k
k.x = n
k.o = n
k.q = h
h.r = a
h.v = k
h.p = k
assert k.o.o.p.q.txt == "h"