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

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

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

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

k = A("k")
c = B("c")
g = C("g")
n = D("n")

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

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

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

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

k = A("k")
c = B("c")
g = C("g")
n = D("n")

k.p = n
k.w = c
k.x = c
k.v = g
c.w = k
c.y = n
c.z = g
g.r = k
n.p = g
n.r = g
n.t = k
n.o = k
assert k.x.w.w.z.txt == "g"