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

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

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

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

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

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

l.r = h
l.t = g
l.p = i
l.v = b
g.y = l
b.o = g
b.w = l
i.v = b
i.u = g
i.o = h
i.w = l
h.r = l
assert h.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.t: B = None
        self.p: D = None
        self.v: C = None
        self.txt = txt

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

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

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

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

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

l.r = h
l.t = g
l.p = i
l.v = b
g.y = l
b.o = g
b.w = l
i.v = b
i.u = g
i.o = h
i.w = l
h.r = l
assert h.r.r.r.txt == "l"