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

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

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

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

n.o = d
e.q = f
e.r = f
e.t = f
f.v = d
d.o = n
assert e.t.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

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

n.o = d
e.q = f
e.r = f
e.t = f
f.v = d
d.o = n
assert e.t.v.o.txt == "n"