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

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

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

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

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

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

i.r = a
f.r = i
f.z = i
f.o = g
g.o = h
g.v = h
g.x = f
g.s = i
g.t = i
h.p = f
h.t = a
a.r = f
assert g.s.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

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

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

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

i.r = a
f.r = i
f.z = i
f.o = g
g.o = h
g.v = h
g.x = f
g.s = i
g.t = i
h.p = f
h.t = a
a.r = f
assert g.s.r.r.r.txt == "i"