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

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

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

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

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

k = A("k")
f = B("f")
g = C("g")
c = D("c")
i = E("i")
n = E("n")

k.p = i
k.x = i
k.v = c
k.u = n
f.s = n
g.y = c
c.w = f
i.w = k
i.p = k
i.r = g
n.w = k
n.p = k
n.r = g
assert c.w.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.v: D = None
        self.x: E = None
        self.u: E = None
        self.txt = txt

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

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

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

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

k = A("k")
f = B("f")
g = C("g")
c = D("c")
i = E("i")
n = E("n")

k.p = i
k.x = i
k.v = c
k.u = n
f.s = n
g.y = c
c.w = f
i.w = k
i.p = k
i.r = g
n.w = k
n.p = k
n.r = g
assert c.w.s.r.txt == "g"