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

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

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

d = A("d")
f = B("f")
n = C("n")

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

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

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

d = A("d")
f = B("f")
n = C("n")

d.q = n
d.v = n
d.u = f
f.v = d
n.t = f
assert n.t.v.v.txt == "n"