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

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

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

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

b = A("b")
c = B("c")
i = C("i")
d = D("d")
a = B("a")
n = A("n")

b.s = a
b.z = a
b.x = d
c.o = a
c.w = a
c.s = b
c.u = i
i.o = b
d.u = b
d.v = a
d.z = c
d.s = n
a.o = c
a.w = c
a.s = n
a.u = i
n.s = c
n.x = d
n.z = a
assert b.z.s.x.v.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: D = None
        self.z: B = None
        self.txt = txt

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

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

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

b = A("b")
c = B("c")
i = C("i")
d = D("d")
a = B("a")
n = A("n")

b.s = a
b.z = a
b.x = d
c.o = a
c.w = a
c.s = b
c.u = i
i.o = b
d.u = b
d.v = a
d.z = c
d.s = n
a.o = c
a.w = c
a.s = n
a.u = i
n.s = c
n.x = d
n.z = a
assert b.z.s.x.v.w.s.txt == "b"