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

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

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

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.u: C = None
        self.w: B = None
        self.s: E = None
        self.p: E = None
        self.txt = txt

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

c = A("c")
d = B("d")
i = C("i")
l = D("l")
b = E("b")
g = A("g")

c.r = g
d.s = b
d.x = b
i.v = l
i.y = d
i.t = b
l.y = b
l.s = b
l.p = b
l.u = i
l.w = d
b.r = l
g.r = c
assert c.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.u: C = None
        self.w: B = None
        self.s: E = None
        self.p: E = None
        self.txt = txt

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

c = A("c")
d = B("d")
i = C("i")
l = D("l")
b = E("b")
g = A("g")

c.r = g
d.s = b
d.x = b
i.v = l
i.y = d
i.t = b
l.y = b
l.s = b
l.p = b
l.u = i
l.w = d
b.r = l
g.r = c
assert c.r.r.r.r.txt == "c"