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

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: B = None
        self.txt = txt

n = A("n")
k = B("k")
e = A("e")
h = B("h")

n.q = h
n.p = k
k.y = h
k.v = h
e.q = h
e.p = h
h.y = k
h.v = k
assert e.p.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: B = None
        self.txt = txt

n = A("n")
k = B("k")
e = A("e")
h = B("h")

n.q = h
n.p = k
k.y = h
k.v = h
e.q = h
e.p = h
h.y = k
h.v = k
assert e.p.v.v.v.txt == "k"