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

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

c = A("c")
d = B("d")
m = A("m")
i = B("i")
f = B("f")
j = A("j")
g = B("g")
k = A("k")
e = B("e")
h = B("h")

c.w = i
c.p = k
d.t = j
m.w = f
m.p = j
i.t = m
f.t = k
j.w = h
j.p = m
g.t = j
k.w = h
k.p = c
e.t = m
h.t = c
assert i.t.w.t.p.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.p: A = None
        self.txt = txt

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

c = A("c")
d = B("d")
m = A("m")
i = B("i")
f = B("f")
j = A("j")
g = B("g")
k = A("k")
e = B("e")
h = B("h")

c.w = i
c.p = k
d.t = j
m.w = f
m.p = j
i.t = m
f.t = k
j.w = h
j.p = m
g.t = j
k.w = h
k.p = c
e.t = m
h.t = c
assert i.t.w.t.p.p.w.txt == "h"