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

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

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

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

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

j = A("j")
g = B("g")
a = C("a")
e = D("e")
k = E("k")
d = D("d")

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

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

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

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

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

j = A("j")
g = B("g")
a = C("a")
e = D("e")
k = E("k")
d = D("d")

j.s = k
j.q = a
g.o = j
a.p = j
a.x = k
a.y = e
e.w = g
e.r = g
e.v = g
k.o = j
k.s = d
d.w = g
d.r = g
d.v = g
assert a.p.s.o.q.y.v.txt == "g"