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

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

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

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

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

e.t = d
i.t = e
k.t = d
k.r = i
g.v = d
n.t = e
l.t = e
a.t = e
d.t = k
d.r = l
assert l.t.t.t.t.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

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

e.t = d
i.t = e
k.t = d
k.r = i
g.v = d
n.t = e
l.t = e
a.t = e
d.t = k
d.r = l
assert l.t.t.t.t.r.t.txt == "e"