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

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

n = A("n")
j = B("j")
h = B("h")
a = B("a")
k = A("k")
m = A("m")
g = A("g")
l = A("l")

n.x = h
j.p = g
j.z = h
h.p = l
h.z = j
a.p = m
a.z = h
k.x = h
m.x = h
g.x = a
l.x = j
assert m.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

n = A("n")
j = B("j")
h = B("h")
a = B("a")
k = A("k")
m = A("m")
g = A("g")
l = A("l")

n.x = h
j.p = g
j.z = h
h.p = l
h.z = j
a.p = m
a.z = h
k.x = h
m.x = h
g.x = a
l.x = j
assert m.x.p.x.txt == "j"