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

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

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

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

a = A("a")
e = B("e")
l = C("l")
c = D("c")
b = C("b")
d = A("d")
g = B("g")

a.s = l
e.z = g
e.o = b
e.r = c
e.t = a
l.x = d
l.s = e
l.w = b
c.z = b
c.r = a
b.x = a
b.s = e
b.w = l
d.s = b
g.z = e
g.o = l
g.r = c
g.t = d
assert a.s.x.s.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

a = A("a")
e = B("e")
l = C("l")
c = D("c")
b = C("b")
d = A("d")
g = B("g")

a.s = l
e.z = g
e.o = b
e.r = c
e.t = a
l.x = d
l.s = e
l.w = b
c.z = b
c.r = a
b.x = a
b.s = e
b.w = l
d.s = b
g.z = e
g.o = l
g.r = c
g.t = d
assert a.s.x.s.w.w.w.w.txt == "b"