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

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

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

l = A("l")
n = B("n")
f = C("f")
g = C("g")
i = A("i")
b = B("b")

l.v = i
n.z = b
f.x = g
f.q = g
f.t = i
g.x = f
g.q = f
g.t = i
i.v = l
b.z = n
assert f.x.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

l = A("l")
n = B("n")
f = C("f")
g = C("g")
i = A("i")
b = B("b")

l.v = i
n.z = b
f.x = g
f.q = g
f.t = i
g.x = f
g.q = f
g.t = i
i.v = l
b.z = n
assert f.x.t.v.txt == "l"