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

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

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

e = A("e")
a = B("a")
d = C("d")

e.q = d
e.v = a
e.u = a
a.t = e
a.p = d
d.t = e
assert a.t.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: B = None
        self.u: B = None
        self.txt = txt

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

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

e = A("e")
a = B("a")
d = C("d")

e.q = d
e.v = a
e.u = a
a.t = e
a.p = d
d.t = e
assert a.t.q.t.txt == "e"