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

class B:
    def __init__(self, txt: str):
        self.p: E = None
        self.z: E = None
        self.r: C = None
        self.txt = txt

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

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

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

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

b.s = n
b.y = a
g.p = c
g.z = c
g.r = n
n.r = d
n.z = b
n.s = g
d.o = a
d.p = n
d.y = b
d.s = b
c.p = n
c.v = b
c.x = a
a.o = d
a.p = n
a.y = b
a.s = b
assert n.s.r.z.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: E = None
        self.z: E = None
        self.r: C = None
        self.txt = txt

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

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

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

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

b.s = n
b.y = a
g.p = c
g.z = c
g.r = n
n.r = d
n.z = b
n.s = g
d.o = a
d.p = n
d.y = b
d.s = b
c.p = n
c.v = b
c.x = a
a.o = d
a.p = n
a.y = b
a.s = b
assert n.s.r.z.s.z.txt == "b"