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

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.o: C = None
        self.y: A = None
        self.v: D = None
        self.r: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

d = A("d")
h = B("h")
m = C("m")
l = D("l")
f = E("f")
g = C("g")

d.s = h
h.x = f
h.o = m
h.y = d
h.r = d
h.v = l
m.s = h
m.r = f
m.y = g
l.r = h
f.t = h
g.s = h
g.r = f
g.y = m
assert g.s.r.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.o: C = None
        self.y: A = None
        self.v: D = None
        self.r: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

d = A("d")
h = B("h")
m = C("m")
l = D("l")
f = E("f")
g = C("g")

d.s = h
h.x = f
h.o = m
h.y = d
h.r = d
h.v = l
m.s = h
m.r = f
m.y = g
l.r = h
f.t = h
g.s = h
g.r = f
g.y = m
assert g.s.r.s.o.txt == "m"