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

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

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

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

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

e.t = k
n.v = d
n.q = e
n.s = c
h.x = d
h.u = l
l.t = i
d.v = g
d.q = k
d.s = h
i.v = g
i.q = e
i.s = c
k.t = e
g.v = n
g.q = e
g.s = c
c.x = d
c.u = l
assert l.t.s.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

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

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

e.t = k
n.v = d
n.q = e
n.s = c
h.x = d
h.u = l
l.t = i
d.v = g
d.q = k
d.s = h
i.v = g
i.q = e
i.s = c
k.t = e
g.v = n
g.q = e
g.s = c
c.x = d
c.u = l
assert l.t.s.x.v.txt == "g"