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

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

i = A("i")
n = B("n")
d = B("d")
e = A("e")

i.v = d
i.y = d
n.u = d
n.q = d
d.u = n
d.q = n
e.v = n
e.y = n
assert d.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: B = None
        self.txt = txt

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

i = A("i")
n = B("n")
d = B("d")
e = A("e")

i.v = d
i.y = d
n.u = d
n.q = d
d.u = n
d.q = n
e.v = n
e.y = n
assert d.q.q.q.txt == "n"