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

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

k = A("k")
d = B("d")
j = B("j")
l = A("l")
c = A("c")
f = B("f")
m = B("m")
a = A("a")
h = B("h")

k.z = f
d.t = a
d.p = j
j.t = k
j.p = h
l.z = f
c.z = j
f.t = k
f.p = m
m.t = k
m.p = j
a.z = m
h.t = k
h.p = d
assert l.z.t.z.p.p.t.z.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

k = A("k")
d = B("d")
j = B("j")
l = A("l")
c = A("c")
f = B("f")
m = B("m")
a = A("a")
h = B("h")

k.z = f
d.t = a
d.p = j
j.t = k
j.p = h
l.z = f
c.z = j
f.t = k
f.p = m
m.t = k
m.p = j
a.z = m
h.t = k
h.p = d
assert l.z.t.z.p.p.t.z.p.t.txt == "k"