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

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

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

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

e = A("e")
c = B("c")
n = C("n")
h = D("h")
j = B("j")
g = C("g")
a = D("a")

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

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

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

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

e = A("e")
c = B("c")
n = C("n")
h = D("h")
j = B("j")
g = C("g")
a = D("a")

e.r = h
c.r = j
c.y = h
c.v = h
c.x = a
n.r = h
n.v = h
n.t = g
n.p = a
h.w = g
h.t = n
j.r = c
j.y = a
j.x = a
j.v = h
g.r = a
g.p = a
g.t = n
g.v = h
a.w = g
a.t = g
assert h.w.t.t.t.t.p.txt == "a"