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

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

m = A("m")
e = B("e")
j = B("j")
k = A("k")
h = A("h")
f = B("f")

m.q = k
m.z = j
e.p = j
e.x = f
j.p = f
j.x = e
k.q = h
k.z = e
h.q = m
h.z = j
f.p = j
f.x = j
assert e.x.x.x.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.z: B = None
        self.txt = txt

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

m = A("m")
e = B("e")
j = B("j")
k = A("k")
h = A("h")
f = B("f")

m.q = k
m.z = j
e.p = j
e.x = f
j.p = f
j.x = e
k.q = h
k.z = e
h.q = m
h.z = j
f.p = j
f.x = j
assert e.x.x.x.p.p.txt == "f"