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

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

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

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

e = A("e")
m = B("m")
i = C("i")
k = D("k")
j = D("j")
d = B("d")

e.w = i
m.u = j
m.w = e
m.p = e
i.r = j
i.s = j
i.q = d
i.t = d
k.t = j
j.t = k
d.u = j
d.w = e
d.p = e
assert k.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

e = A("e")
m = B("m")
i = C("i")
k = D("k")
j = D("j")
d = B("d")

e.w = i
m.u = j
m.w = e
m.p = e
i.r = j
i.s = j
i.q = d
i.t = d
k.t = j
j.t = k
d.u = j
d.w = e
d.p = e
assert k.t.t.t.t.t.txt == "j"