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

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

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

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

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

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

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

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

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

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

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