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

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

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

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

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

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

a.r = i
a.q = i
a.x = i
a.v = b
g.p = a
b.x = a
b.o = g
h.s = i
h.y = g
i.q = b
i.x = h
i.w = g
assert g.p.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.q: E = None
        self.x: E = None
        self.v: C = None
        self.txt = txt

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

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

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

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

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

a.r = i
a.q = i
a.x = i
a.v = b
g.p = a
b.x = a
b.o = g
h.s = i
h.y = g
i.q = b
i.x = h
i.w = g
assert g.p.v.o.txt == "g"