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

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

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

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

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

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

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

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

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

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

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

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

a.s = g
a.r = f
a.v = i
i.v = f
i.x = g
i.y = a
i.t = a
d.o = f
d.z = a
f.t = n
f.v = i
g.q = i
g.x = i
g.p = d
g.z = f
n.o = f
n.z = a
assert a.v.v.v.x.txt == "g"