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

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

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

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

k = A("k")
d = B("d")
b = C("b")
n = D("n")
g = D("g")

k.o = g
k.t = d
k.x = b
d.w = n
d.y = k
b.z = d
b.y = g
n.w = b
n.s = b
n.t = g
n.o = g
g.w = b
g.s = b
g.t = n
g.o = n
assert k.o.s.z.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.t: B = None
        self.x: C = None
        self.txt = txt

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

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

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

k = A("k")
d = B("d")
b = C("b")
n = D("n")
g = D("g")

k.o = g
k.t = d
k.x = b
d.w = n
d.y = k
b.z = d
b.y = g
n.w = b
n.s = b
n.t = g
n.o = g
g.w = b
g.s = b
g.t = n
g.o = n
assert k.o.s.z.y.o.txt == "g"