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

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

b = A("b")
e = B("e")
i = B("i")
j = A("j")
n = A("n")
k = A("k")
g = A("g")
m = A("m")

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

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

b = A("b")
e = B("e")
i = B("i")
j = A("j")
n = A("n")
k = A("k")
g = A("g")
m = A("m")

b.z = e
e.x = i
e.p = k
i.x = e
i.p = k
j.z = e
n.z = i
k.z = e
g.z = e
m.z = i
assert n.z.x.p.z.txt == "e"