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

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

n = A("n")
f = B("f")
e = B("e")
l = B("l")
c = B("c")
m = B("m")
h = A("h")

n.s = h
n.q = h
f.p = h
f.x = c
e.p = h
e.x = l
l.p = n
l.x = c
c.p = n
c.x = e
m.p = h
m.x = c
h.s = n
h.q = n
assert e.p.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: A = None
        self.txt = txt

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

n = A("n")
f = B("f")
e = B("e")
l = B("l")
c = B("c")
m = B("m")
h = A("h")

n.s = h
n.q = h
f.p = h
f.x = c
e.p = h
e.x = l
l.p = n
l.x = c
c.p = n
c.x = e
m.p = h
m.x = c
h.s = n
h.q = n
assert e.p.s.q.txt == "h"