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

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

j = A("j")
c = B("c")
h = B("h")
e = A("e")

j.u = h
c.q = e
h.q = e
e.u = c
assert c.q.u.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

j = A("j")
c = B("c")
h = B("h")
e = A("e")

j.u = h
c.q = e
h.q = e
e.u = c
assert c.q.u.q.u.txt == "c"