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

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

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

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

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

g = A("g")
i = B("i")
j = C("j")
e = D("e")
n = E("n")
h = B("h")

g.v = e
g.x = n
g.r = j
i.z = j
j.s = g
e.r = n
n.v = g
n.s = h
n.o = j
h.z = j
assert h.z.s.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.x: E = None
        self.r: C = None
        self.txt = txt

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

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

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

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

g = A("g")
i = B("i")
j = C("j")
e = D("e")
n = E("n")
h = B("h")

g.v = e
g.x = n
g.r = j
i.z = j
j.s = g
e.r = n
n.v = g
n.s = h
n.o = j
h.z = j
assert h.z.s.r.s.txt == "g"