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

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

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

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

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

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

n.s = i
h.r = j
a.y = g
a.z = n
a.r = h
a.x = h
i.s = b
i.q = b
i.y = h
i.x = h
i.v = n
b.t = n
g.t = j
j.s = i
assert j.s.x.r.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

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

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

n.s = i
h.r = j
a.y = g
a.z = n
a.r = h
a.x = h
i.s = b
i.q = b
i.y = h
i.x = h
i.v = n
b.t = n
g.t = j
j.s = i
assert j.s.x.r.s.v.s.txt == "i"