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

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

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

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

e = A("e")
n = B("n")
c = C("c")
l = D("l")
g = D("g")
i = C("i")
d = A("d")
h = B("h")

e.t = g
e.o = l
e.s = d
n.r = c
n.t = d
c.q = n
c.r = n
c.x = i
c.w = l
l.x = g
l.s = g
l.y = d
g.x = l
g.s = l
g.y = e
i.q = n
i.x = c
i.r = h
i.w = l
d.t = l
d.o = l
d.s = e
h.r = c
h.t = e
assert n.t.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.o: D = None
        self.s: A = None
        self.txt = txt

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

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

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

e = A("e")
n = B("n")
c = C("c")
l = D("l")
g = D("g")
i = C("i")
d = A("d")
h = B("h")

e.t = g
e.o = l
e.s = d
n.r = c
n.t = d
c.q = n
c.r = n
c.x = i
c.w = l
l.x = g
l.s = g
l.y = d
g.x = l
g.s = l
g.y = e
i.q = n
i.x = c
i.r = h
i.w = l
d.t = l
d.o = l
d.s = e
h.r = c
h.t = e
assert n.t.s.s.s.s.s.s.txt == "d"