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

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.w: D = None
        self.q: C = None
        self.r: E = None
        self.s: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: A = None
        self.txt = txt

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

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

g.s = f
c.t = l
c.q = l
c.s = l
c.w = f
c.r = m
l.x = c
f.w = c
f.q = g
m.p = c
m.w = c
assert g.s.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.w: D = None
        self.q: C = None
        self.r: E = None
        self.s: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: A = None
        self.txt = txt

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

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

g.s = f
c.t = l
c.q = l
c.s = l
c.w = f
c.r = m
l.x = c
f.w = c
f.q = g
m.p = c
m.w = c
assert g.s.w.r.txt == "m"