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

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

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

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

a = A("a")
h = B("h")
f = C("f")
g = D("g")
b = A("b")
m = D("m")
n = C("n")

a.v = n
a.s = n
a.o = g
a.z = m
h.t = g
h.x = n
h.u = a
f.z = a
f.s = n
g.u = h
g.s = h
g.w = f
g.v = m
b.v = n
b.s = n
b.o = g
b.z = g
m.u = h
m.s = h
m.w = f
m.v = g
n.z = a
n.s = f
assert a.v.s.z.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.o: D = None
        self.s: C = None
        self.z: D = None
        self.txt = txt

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

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

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

a = A("a")
h = B("h")
f = C("f")
g = D("g")
b = A("b")
m = D("m")
n = C("n")

a.v = n
a.s = n
a.o = g
a.z = m
h.t = g
h.x = n
h.u = a
f.z = a
f.s = n
g.u = h
g.s = h
g.w = f
g.v = m
b.v = n
b.s = n
b.o = g
b.z = g
m.u = h
m.s = h
m.w = f
m.v = g
n.z = a
n.s = f
assert a.v.s.z.z.w.txt == "f"