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

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

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

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

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

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

l.s = h
m.q = f
m.w = f
m.y = l
m.r = g
h.s = m
g.w = f
b.v = l
f.v = l
assert b.v.s.s.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

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

l.s = h
m.q = f
m.w = f
m.y = l
m.r = g
h.s = m
g.w = f
b.v = l
f.v = l
assert b.v.s.s.r.w.txt == "f"