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

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

k = A("k")
d = B("d")
c = A("c")
h = A("h")
n = A("n")
i = B("i")
e = A("e")

k.t = i
k.w = n
d.v = c
d.w = c
c.t = d
c.w = h
h.t = i
h.w = c
n.t = d
n.w = c
i.v = k
i.w = n
e.t = i
e.w = c
assert h.w.t.v.t.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.w: A = None
        self.txt = txt

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

k = A("k")
d = B("d")
c = A("c")
h = A("h")
n = A("n")
i = B("i")
e = A("e")

k.t = i
k.w = n
d.v = c
d.w = c
c.t = d
c.w = h
h.t = i
h.w = c
n.t = d
n.w = c
i.v = k
i.w = n
e.t = i
e.w = c
assert h.w.t.v.t.w.t.w.txt == "c"