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

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

l = A("l")
a = B("a")
c = A("c")
j = A("j")
k = B("k")
i = A("i")
e = A("e")

l.w = e
l.t = e
a.p = i
c.w = l
c.t = i
j.w = c
j.t = i
k.p = i
i.w = j
i.t = j
e.w = i
e.t = i
assert e.w.t.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: A = None
        self.txt = txt

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

l = A("l")
a = B("a")
c = A("c")
j = A("j")
k = B("k")
i = A("i")
e = A("e")

l.w = e
l.t = e
a.p = i
c.w = l
c.t = i
j.w = c
j.t = i
k.p = i
i.w = j
i.t = j
e.w = i
e.t = i
assert e.w.t.w.w.w.w.txt == "i"