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

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

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

e = A("e")
l = B("l")
h = C("h")

e.u = h
l.q = h
l.x = e
h.x = l
assert e.u.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

e = A("e")
l = B("l")
h = C("h")

e.u = h
l.q = h
l.x = e
h.x = l
assert e.u.x.q.txt == "h"