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

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

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

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

n = A("n")
b = B("b")
i = C("i")
f = D("f")
g = A("g")

n.v = g
n.x = g
n.s = i
b.z = i
b.s = i
b.y = f
i.u = b
i.x = f
i.z = n
i.s = n
f.u = b
f.x = b
f.v = i
g.v = n
g.x = n
g.s = i
assert i.z.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.x: A = None
        self.s: C = None
        self.txt = txt

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

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

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

n = A("n")
b = B("b")
i = C("i")
f = D("f")
g = A("g")

n.v = g
n.x = g
n.s = i
b.z = i
b.s = i
b.y = f
i.u = b
i.x = f
i.z = n
i.s = n
f.u = b
f.x = b
f.v = i
g.v = n
g.x = n
g.s = i
assert i.z.s.s.txt == "n"