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

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: D = None
        self.z: A = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
h = C("h")
g = D("g")

n.z = l
l.t = n
l.z = n
l.v = g
h.z = g
h.x = n
g.v = l
g.x = l
g.s = l
g.p = h
assert h.x.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: D = None
        self.z: A = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
h = C("h")
g = D("g")

n.z = l
l.t = n
l.z = n
l.v = g
h.z = g
h.x = n
g.v = l
g.x = l
g.s = l
g.p = h
assert h.x.z.t.txt == "n"