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.u: B = None
        self.q: B = None
        self.txt = txt

m = A("m")
i = B("i")
c = B("c")

m.q = i
m.p = c
i.u = c
i.q = c
c.u = i
c.q = i
assert c.u.u.q.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.u: B = None
        self.q: B = None
        self.txt = txt

m = A("m")
i = B("i")
c = B("c")

m.q = i
m.p = c
i.u = c
i.q = c
c.u = i
c.q = i
assert c.u.u.q.txt == "i"