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

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.p: E = None
        self.w: D = None
        self.v: D = None
        self.y: A = None
        self.txt = txt

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

e = A("e")
m = B("m")
a = C("a")
g = D("g")
c = E("c")
k = D("k")
n = D("n")

e.r = m
e.y = g
m.t = c
a.w = e
a.v = k
g.r = n
g.v = n
g.p = c
g.w = k
g.y = e
c.s = a
k.r = g
k.v = g
k.p = c
k.w = n
k.y = e
n.r = k
n.w = k
n.v = k
n.p = c
n.y = e
assert a.v.p.s.w.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.p: E = None
        self.w: D = None
        self.v: D = None
        self.y: A = None
        self.txt = txt

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

e = A("e")
m = B("m")
a = C("a")
g = D("g")
c = E("c")
k = D("k")
n = D("n")

e.r = m
e.y = g
m.t = c
a.w = e
a.v = k
g.r = n
g.v = n
g.p = c
g.w = k
g.y = e
c.s = a
k.r = g
k.v = g
k.p = c
k.w = n
k.y = e
n.r = k
n.w = k
n.v = k
n.p = c
n.y = e
assert a.v.p.s.w.r.t.txt == "c"