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

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

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

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

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

k = A("k")
i = B("i")
e = C("e")
b = D("b")
g = E("g")

k.r = b
k.s = i
i.w = k
i.u = g
e.y = k
b.q = k
b.p = k
b.y = k
b.r = i
g.p = e
g.o = k
assert g.p.y.s.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.s: B = None
        self.txt = txt

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

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

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

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

k = A("k")
i = B("i")
e = C("e")
b = D("b")
g = E("g")

k.r = b
k.s = i
i.w = k
i.u = g
e.y = k
b.q = k
b.p = k
b.y = k
b.r = i
g.p = e
g.o = k
assert g.p.y.s.w.s.txt == "i"